Generics-Related Refactorings for Java in Eclipse
Courtyard (room B)
Tuesday, 12:00, 45 minutes
Adam Kiezun, MIT
Robert Fuhrer, IBM T.J. Watson Research Center
Frank Tip, IBM T.J. Watson Research Center
Markus Keller, IBM Research
Demonstration number: 5We propose a demonstration of generics-related refactorings for Java, some of which have been recently added to Eclipse 3.1 and presented at ECOOP?05 as a technical paper by the present authors. These refactorings facilitate migration of pre-generic libraries and applications to take advantage of the improved reuse and clarity provided by parametric polymorphism in OO programs. The automation of the refactorings requires involved static analyses. It also poses challenging usability issues reflecting the complications that programmers face in performing the transformations manually. During the demonstration, we will give an overview of the technical challenges, and highlight the approach we took in addressing the more difficult ones. Our implementation, which we will discuss, is build on top of Eclipse?s refactoring and type constraint infrastructure. We will present: * Infer Type Arguments - helps in migrating Java application code to generics by determining what concrete types are used for each actual type parameter in the original program, modifying declarations and allocations sites where necessary, and removing casts that have been rendered redundant. This refactoring is included in Eclipse 3.1. * Introduce Type Parameter - facilitates converting non-generic Java libraries to generics, conveniently and safely for existing clients. It adds a formal type parameter to a class to be used in place of the presently-declared type of a declaration, thus making the class generic. Other necessary changes are performed, possibly including adding new type parameters to related classes. The refactoring infers wildcards which increases the flexibility of the parameterization.