Refactoring Java Applications to Use Generic Libraries

The goal of this project to to create algortihms and tool support for the problem of migrating Java applications that predate Java 1.5 to take advantage of generics libaries.

Work abstract:
Java 1.5 generics enable the creation of reusable container classes with compiler-enforced type safe usage. This eliminates the need for potentially unsafe down-casts when retrieving elements from containers. We present a refactoring that migrates occurrences of non-generic library classes to generic versions of those classes. This involves inferring actual type parameters for allocation sites and declarations using an existing framework of type constraints, and removing casts that have been rendered redundant. The refactoring was implemented in Eclipse, a popular open-source development environment for Java, and will be part of the forthcoming Eclipse 3.1 release. We evaluated our work by refactoring several Java programs that use non-generic container classes from the standard collections framework to use Java 1.5's generic versions of these classes instead. Our results indicate that in these benchmarks, on average, 52.2% of the casts are removed, and that 94.1% of the compiler warnings related to the use of raw types are eliminated. Our approach distinguishes itself from the state-of-the-art work by Donovan et al. by being more scalable, by its ability to accommodate user-defined subtypes of generic library classes, and by being fully source-based.


Related work at PAG:
As mentioned in the abstract, this work is related to and replaces our previous project, Jiggetai.