Making the future safe for the past: adding genericity to the Java programming language

We present GJ, a design that extends the Java programming language with generic types and methods. These are both explained and implemented by translation into the unextended language. The translation closely mimics the way generics are emulated by programmers: it erases all type parameters, maps type variables to their bounds, and inserts casts where needed. Some subtleties of the translation are caused by the handling of overriding.GJ increases expressiveness and safety: code utilizing generic libraries is no longer buried under a plethora of casts, and the corresponding casts inserted by the translation are guaranteed to not fail.GJ is designed to be fully backwards compatible with the current Java language, which simplifies the transition from non-generic to generic programming. In particular, one can retrofit existing library classes with generic interfaces without changing their code.An implementation of GJ has been written in GJ, and is freely available on the web.

[1]  Martin Odersky,et al.  A Statically Safe Alternative to Virtual Types , 1998, ECOOP.

[2]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[3]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[4]  Gilad Bracha,et al.  GJ: Extending the Java programming language with type parameters , 1999 .

[5]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[6]  John C. Mitchell,et al.  F-bounded polymorphism for object-oriented programming , 1989, FPCA.

[7]  Paul Roe,et al.  Lightweight Parametric Polymorphism for Oberon , 1997, JMLC.

[8]  Andrew K. Wright Simple imperative polymorphism , 1995, LISP Symb. Comput..

[9]  Kresten Krab Thorup Genericity in Java with Virtual Types , 1997, ECOOP.

[10]  Martin Odersky,et al.  Pizza into Java: translating theory into practice , 1997, POPL '97.

[11]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[12]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[13]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[14]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[15]  Gilad Bracha,et al.  Strongtalk: typechecking Smalltalk in a production environment , 1993, OOPSLA '93.

[16]  Scott F. Smith,et al.  Sound polymorphic type inference for objects , 1995, OOPSLA.

[17]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[18]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[19]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

[20]  Mads Torgersen Virtual types are statically safe , 1998 .