Refactoring Java generics by inferring wildcards, in practice

Gespeichert in:
Bibliographische Detailangaben
Titel: Refactoring Java generics by inferring wildcards, in practice
Autoren: Altidor, John, Smaragdakis, Yannis
Weitere Verfasser: European Research Council, Seventh Framework Programme, General Secretariat for Research and Technology
Quelle: ACM SIGPLAN Notices ; volume 49, issue 10, page 271-290 ; ISSN 0362-1340 1558-1160
Verlagsinformationen: Association for Computing Machinery (ACM)
Publikationsjahr: 2014
Beschreibung: 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.
Publikationsart: article in journal/newspaper
Sprache: English
DOI: 10.1145/2714064.2660203
Verfügbarkeit: https://doi.org/10.1145/2714064.2660203
https://dl.acm.org/doi/10.1145/2714064.2660203
https://dl.acm.org/doi/pdf/10.1145/2714064.2660203
Rights: https://www.acm.org/publications/policies/copyright_policy#Background
Dokumentencode: edsbas.1A549A14
Datenbank: BASE
Beschreibung
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.
DOI:10.1145/2714064.2660203