Refactoring Java generics by inferring wildcards, in practice
-
Published:2014-12-31
Issue:10
Volume:49
Page:271-290
-
ISSN:0362-1340
-
Container-title:ACM SIGPLAN Notices
-
language:en
-
Short-container-title:SIGPLAN Not.
Author:
Altidor John1,
Smaragdakis Yannis2
Affiliation:
1. University of Massachusetts Amherst, Amherst, MA, USA
2. University of Athens, Ilisia, Greece
Abstract
Wildcard annotations can improve the generality of Java generic libraries, but require heavy manual effort. We present an algorithm for refactoring and inferring more general type instantiations of Java generics using wildcards. Compared to past approaches, our work is practical and immediately applicable: we assume no changes to the Java type system, while taking into account all its intricacies. Our system allows users to select declarations (variables, method parameters, return types, etc.) to generalize and considers declarations not declared in available source code. It then performs an inter-procedural flow analysis and a method body analysis, in order to generalize type signatures. We evaluate our technique on six Java generic libraries. We find that 34% of available declarations of variant type signatures can be generalized - i.e., relaxed with more general wildcard types. On average, 146 other declarations need to be updated when a declaration is generalized, showing that this refactoring would be too tedious and error-prone to perform manually.
Funder
European Research Council
Seventh Framework Programme
General Secretariat for Research and Technology
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Reference18 articles.
1. Taming the wildcards
2. Java Wildcards Meet Definition-Site Variance
3. Apache. Apache commons-collections library. http://larvalabs.com/collections/. Version 4.01. Apache. Apache commons-collections library. http://larvalabs.com/collections/. Version 4.01.
4. K. Boumillion and J. Levy. Guava: Google core libraries for Java 1.5+. http://code.google.com/p/guava-libraries/. Release 8. K. Boumillion and J. Levy. Guava: Google core libraries for Java 1.5+. http://code.google.com/p/guava-libraries/. Release 8.
5. A Model for Java with Wildcards