A Recipe for Raw Types

The design of GJ (Bracha, Odersky, Stoutamire and Wadler), an extension of Java with parametric polymorphism, was significantly affected by the issue of compatibility between legacy Java code and new GJ code. In particular, the introduction of raw types made it easier to interface polymorphic code with monomorphic code. In GJ, for example, a polymorphic class List, parameterized by the element type X, provides not only parameterized types such as List or List but also the raw type List; then, a Java class using List can be compiled without adding element types to where List is used. Raw types, therefore, can reduce (or defer, at least) programmers’ burden of modifying their old Java code to match with new polymorphic code. From the type-theoretic point of view, raw types are close to existential types in the sense that clients using a raw type C expect some implementation of a polymorphic class of the same name C. Unlike ordinary existential types, however, raw types allow several unsafe operations such as coercion from the raw type List, whose element type is abstract, to List for any concrete type T. In this paper, basing on Featherweight GJ, proposed by the authors as a tiny core language of GJ, we formalize a type system and direct reduction semantics of raw types. The bottom type, which is subtype of any type, plays a key role in our type-preserving reduction semantics. In the course of the work, we have found a flaw in the typing rules from the GJ specification; type soundness is proved with respect to a repaired version of the type system.

[1]  John C. Mitchell,et al.  F-bounded quantification for object-oriented programming , 1989 .

[2]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

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

[4]  Mirko Viroli,et al.  Parametric polymorphism in Java: an approach to translation based on reflective features , 2000, OOPSLA '00.

[5]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[6]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[7]  Atsushi Igarashi,et al.  On Inner Classes , 2000, ECOOP.

[8]  Luca Cardelli,et al.  An Extension of System F with Subtyping , 1991, TACS.

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

[10]  Stephen N. Freund,et al.  Adding type parameterization to the Java language , 1997, OOPSLA '97.

[11]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[12]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

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

[14]  John C. Mitchell,et al.  Abstract types have existential types , 1985, POPL.

[15]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.