On Inner Classes

Inner classes in object-oriented languages play a role similar to nested function definitions in functional languages, allowing an object to export other objects with direct access to its own methods and instance variables. However, the similarity is deceptive: a close look at inner classes reveals significant subtleties arising from their interactions with inheritance. The goal of this work is a precise understanding of the essential features of inner classes; our object of study is a fragment of Java with inner classes and inheritance (and almost nothing else). We begin by giving a direct reduction semantics for this language. We then give an alternative semantics by translation into a yet smaller language with only top-level classes, closely following Java's Inner Classes Specification. We prove that the two semantics coincide, in the sense that translation commutes with reduction, and that both are type-safe.

[1]  Patrick Chan,et al.  The Java™ Class Libraries, Volume 2: java.applet, java.awt, java.beans , 1997 .

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

[3]  Neal Glew Object Closure Conversion , 1999, Electron. Notes Theor. Comput. Sci..

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

[5]  Patrick Chan,et al.  The Java class libraries , 1998 .

[6]  Tobias Nipkow,et al.  Javalight is type-safe—definitely , 1998, POPL '98.

[7]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA 1989.

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

[9]  Martín Abadi,et al.  Protection in Programming-Language Translations , 1998, ICALP.

[10]  Ole Lehrmann Madsen,et al.  Semantic analysis of virtual classes and nested classes , 1999, OOPSLA '99.

[11]  G.D. Plotkin,et al.  LCF Considered as a Programming Language , 1977, Theor. Comput. Sci..

[12]  Don Syme,et al.  Proving Java Type Soundness , 1999, Formal Syntax and Semantics of Java.

[13]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

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

[15]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[16]  Sarfraz Khurshid,et al.  Is the Java Type System Sound? , 1999, Theory Pract. Object Syst..