Converting Java programs to use generic libraries

Download: PDF, slides (PDF).

“Converting Java programs to use generic libraries” by Alan Donovan, Adam Kieżun, Matthew S. Tschantz, and Michael D. Ernst. In Object-Oriented Programming Systems, Languages, and Applications (OOPSLA 2004), (Vancouver, BC, Canada), October 26-28, 2004, pp. 15-34.
A previous version appeared as MIT Laboratory for Computer Science technical report MIT-LCS-TR-940, (Cambridge, MA), March 30, 2004.
A previous version appeared as “Inference of generic types in Java” by Alan Donovan and Michael D. Ernst. MIT Laboratory for Computer Science technical report MIT/LCS/TR-889, (Cambridge, MA), March 22, 2003.


Java 1.5 will include a type system (called JSR-14) that supports parametric polymorphism, or generic classes. This will bring many benefits to Java programmers, not least because current Java practice makes heavy use of logically-generic classes, including container classes.

Translation of Java source code into semantically equivalent JSR-14 source code requires two steps: parameterization (adding type parameters to class definitions) and instantiation (adding the type arguments at each use of a parameterized class). Parameterization need be done only once for a class, whereas instantiation must be performed for each client, of which there are potentially many more. Therefore, this work focuses on the instantiation problem. We present a technique to determine sound and precise JSR-14 types at each use of a class for which a generic type specification is available. Our approach uses a precise and context-sensitive pointer analysis to determine possible types at allocation sites, and a set-constraint-based analysis (that incorporates guarded, or conditional, constraints) to choose consistent types for both allocation and declaration sites. The technique handles all features of the JSR-14 type system, notably the raw types that provide backward compatibility. We have implemented our analysis in a tool that automatically inserts type parameters into Java code, and we report its performance when applied to a number of real-world Java programs.

Download: PDF, slides (PDF).

BibTeX entry:

   author = {Alan Donovan and Adam Kie{\.z}un and Matthew S. Tschantz and
	Michael D. Ernst},
   title = {Converting {Java} programs to use generic libraries},
   booktitle = {Object-Oriented Programming Systems, Languages, and
	Applications (OOPSLA 2004)},
   pages = {15--34},
   address = {Vancouver, BC, Canada},
   month = {October~26--28,},
   year = {2004}

(This webpage was created with bibtex2web.)

Back to Michael Ernst's publications.