Computer Science Colloquium

Efficiently Refactoring Java Applications to Use Generic Libraries

Frank Tip
IBM Research

Friday, January 21, 2005 11:30 A.M.
Room 1302 Warren Weaver Hall
251 Mercer Street
New York, NY 10012-1185

Colloquium Information:


Robert Grimm, (212) 998-3143


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 by being more scalable, by its ability to accommodate user-defined subtypes of generic library classes, and by being fully source-based.

This is joint work with Robert Fuhrer, Adam Kiezun, and Julian Dolby


Frank Tip received his Ph.D. in 1995 from the University of Amsterdam. He has been at the IBM T.J. Watson Research Center since then, where he is now managing the Program Analysis and Transformation group. His research interests include: analysis and transformation of object-oriented languages, program slicing, refactoring, and high-level optimization techniques.

top | contact