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.
Supplemental Material
Available for Download
Please, email questions to [email protected]
Artifact Overview for Paper #35 of OOPSLA 2014
Please, email questions to [email protected]
- J. Altidor, S. S. Huang, and Y. Smaragdakis. Taming the wildcards: Combining definition- and use-site variance. In Programming Language Design and Implementation (PLDI), 2011. Google Scholar
Digital Library
- J. Altidor, C. Reichenbach, and Y. Smaragdakis. Java wildcards meet definition-site variance. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP), 2012. Google Scholar
Digital Library
- Apache. Apache commons-collections library. http://larvalabs.com/collections/. Version 4.01.Google Scholar
- K. Boumillion and J. Levy. Guava: Google core libraries for Java 1.5+. http://code.google.com/p/guava-libraries/. Release 8.Google Scholar
- N. Cameron, S. Drossopoulou, and E. Ernst. A model for Java with wildcards. In European Conf. on Object-Oriented Programming (ECOOP), 2008. Google Scholar
Digital Library
- P. Canning, W. Cook, W. Hill, W. Olthoff, and J. C. Mitchell. F-bounded polymorphism for object-oriented programming. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, 1989. Google Scholar
Digital Library
- W.-N. Chin, F. Craciun, S.-C. Khoo, and C. Popeea. A flow-based approach for variant parametric types. In Proceedings of Conf. on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), 2006. Google Scholar
Digital Library
- F. Craciun, W.-N. Chin, G. He, and S. Qin. An interval-based inference of variant parametric types. In Proceedings of the 18th European Symposium on Programming (ESOP), 2009. Google Scholar
Digital Library
- J.-M. Dautelle et al. Jscience. http://jscience.org/. Version 4.3.Google Scholar
- E. Friedman and R. Eden. Gnu Trove: High-performance collections library for Java. http://trove4j.sourceforge.net/. Version 2.1.0.Google Scholar
- J. Gosling, B. Joy, G. Steele, G. Bracha, and A. Buckley. The Java Language Specification. California, USA, 7th edition, 2012.Google Scholar
- A. Igarashi, B. C. Pierce, and P.Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst., 23(3):396--450, 2001. Google Scholar
Digital Library
- A. Igarashi and M. Viroli. Variant parametric types: A flexible subtyping scheme for generics. ACM Trans. Program. Lang. Syst., 28(5):795--847, 2006. Google Scholar
Digital Library
- A. Kennedy and B. Pierce. On decidability of nominal sub-typing with variance. FOOL/WOOD, 2007.Google Scholar
- A. Kiezun, M. D. Ernst, F. Tip, and R. M. Fuhrer. Refactoring for parameterizing Java classes. In Proceedings of the 29th International Conference on Software Engineering, 2007. Google Scholar
Digital Library
- M. Odersky. The Scala Language Specification v 2.9. http://www.scala-lang.org/docu/files/ScalaReference.pdf, 2014.Google Scholar
- A. Salcianu. Java program analysis utilities library. http://jpaul.sourceforge.net/. Version 2.5.1.Google Scholar
- R. Tate, A. Leung, and S. Lerner. Taming wildcards in Java's type system. In Programming Language Design and Implementation (PLDI), 2011. Google Scholar
Digital Library
Index Terms
Refactoring Java generics by inferring wildcards, in practice
Recommendations
Refactoring Java generics by inferring wildcards, in practice
OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & ApplicationsWildcard 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 ...
Taming the wildcards: combining definition- and use-site variance
PLDI '11Variance allows the safe integration of parametric and subtype polymorphism. Two flavors of variance, definition-site versus use-site variance, have been studied and have had their merits hotly debated. Definition-site variance (as in Scala and C#) ...
Taming the wildcards: combining definition- and use-site variance
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and ImplementationVariance allows the safe integration of parametric and subtype polymorphism. Two flavors of variance, definition-site versus use-site variance, have been studied and have had their merits hotly debated. Definition-site variance (as in Scala and C#) ...







Comments