Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1028976.1028979acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

Converting java programs to use generic libraries

Published: 01 October 2004 Publication History

Abstract

Java 1.5 will include a type system (called JSR-14) that supports <i>parametric polymorphism</i>, or <i>generic</i> classes. This will bring many benefits to Java programmers, not least because current Java practice makes heavy use of logically-generic classes, including container classes.
Translation of Java source code into semantically equivalent JSR-14 source code requires two steps: parameterization (adding type parameters to class definitions) and instantiation (adding the type arguments at each use of a parameterized class). Parameterization need be done only once for a class, whereas instantiation must be performed for each client, of which there are potentially many more. Therefore, this work focuses on the instantiation problem. We present a technique to determine sound and precise JSR-14 types at each use of a class for which a generic type specification is available. Our approach uses a precise and context-sensitive pointer analysis to determine possible types at allocation sites, and a set-constraint-based analysis (that incorporates guarded, or conditional, constraints) to choose consistent types for both allocation and declaration sites. The technique handles all features of the JSR-14 type system, notably the raw types that provide backward compatibility. We have implemented our analysis in a tool that automatically inserts type parameters into Java code, and we report its performance when applied to a number of real-world Java programs.

References

[1]
O. Agesen. The cartesian product algorithm: Simple and precise type inference of parametric polymorphism. In ECOOP, pages 2--26, Aug. 1996.
[2]
A. Aiken and E. L. Wimmers. Type inclusion constraints and type inference. In Functional Programming Languages and Computer Architecture, pages 31--41, June 1993.
[3]
D. F. Bacon and P. F. Sweeney. Fast static analysis of C++ virtual function calls. In OOPSLA, pages 324--341, Oct. 1996.
[4]
G. Bracha, N. Cohen, C. Kemper, S. Mark, M. Odersky, S.-E. Panitz, D. Stoutamire, K. Thorup, and P. Wadler. Adding generics to the Java programming language: Participant draft specification. Technical report, Sun Microsystems, Apr. 27, 2001.
[5]
G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. GJ specification. http://www.cis.unisa.edu.au/ pizza/gj/Documents/#gj-specification, May 1998.
[6]
G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA, pages 183--200, Oct. 1998.
[7]
L. Cardelli and P. Wegner. On understanding types, data abstraction, and polymorphism. ACM Computing Surveys, 17(4):471--522, Dec. 1985.
[8]
R. Cartwright and M. Fagan. Soft typing. In PLDI, pages 278--292, June 1991.
[9]
R. Cartwright and G. L. Steele Jr. Compatable genericity with run-time types for the Java programming language. In OOPSLA, pages 201--215, Oct. 1998.
[10]
C. Chambers and D. Ungar. Customization: Optimizing compiler technology for Self, a dynamically-typed object-oriented language. In PLDI, pages 146--160, Portland, OR, USA, June 1989.
[11]
C. Chambers, D. Ungar, and E. Lee. An efficient implementation of Self, a dynamically-typed object-oriented language based on prototypes. In OOPSLA, pages 49--70, Oct. 1989.
[12]
OmniCore CodeGuide. http://www.omnicore.com/codeguide.htm.
[13]
B. De Sutter, F. Tip, and J. Dolby. Customization of Java library classes using type constraints and profile information. In ECOOP, June 2004.
[14]
J. Dean, D. Grove, and C. Chambers. Optimization of object-oriented programs using static class hierarchy analysis. In ECOOP, pages 77--101, Aug. 1995.
[15]
A. Donovan. Converting Java programs to use generic libraries. Master's thesis, MIT Dept. of EECS, Sept. 2004.
[16]
A. Donovan and M. D. Ernst. Inference of generic types in Java. Technical Report MIT/ LCS/ TR-889, MIT Lab for Computer Science, Mar. 22, 2003.
[17]
D. Duggan. Modular type-based reverse engineering of parameterized types in Java code. In OOPSLA, pages 97--113, Nov. 1999.
[18]
Eclipse project. http://www.eclipse.org/.
[19]
J. Eifrig, S. Smith, and V. Trifonov. Sound polymorphic type inference for objects. In OOPSLA, pages 169--184, Oct. 1995.
[20]
E. Gagnon, L. J. Hendren, and G. Marceau. Efficient inference of static types for Java bytecode. In Static Analysis Symposium, pages 199--219, June 2000.
[21]
J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison Wesley, Boston, MA, second edition, 2000.
[22]
D. Grove and C. Chambers. A framework for call graph construction algorithms. ACM Transactions on Programming Languages and Systems, 23(6):685--746, Nov. 2001.
[23]
M. Hind and A. Pioli. Evaluating the effectiveness of pointer alias analyses. Science of Computer Programming, 39(1):31--55, Jan. 2001.
[24]
JetBrains IntelliJ IDEA. http://www.intellij.com/idea/.
[25]
A. Igarashi, B. C. Pierce, and P. Wadler. A recipe for raw types. In FOOL, London, Jan. 2001.
[26]
A. Igarashi and M. Viroli. On variance-based subtyping for parametric types. In ECOOP, pages 441--469, June 2002.
[27]
JavaSoft, Sun Microsystems. Prototype for JSR014: Adding generics to the Java programming language v. 1.3. http://jcp.org/jsr/detail/14.html, May 7, 2001.
[28]
B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Trans. Prog. Lang. Syst., 16(6):1811--1841, Nov. 1994.
[29]
B. McAdam, A. Kennedy, and N. Benton. Type inference for MLj. In Scottish Functional Programming Workshop, pages 159--172, 2001. Trends in Functional Programming, volume 2, Chapter 13.
[30]
R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348--375, 1978.
[31]
A. C. Myers, J. A. Bank, and B. Liskov. Parameterized types for Java. In POPL, pages 132--145, Jan. 1997.
[32]
R. O'Callahan. Generalized Aliasing as a Basis for Program Analysis Tools. PhD thesis, Carnegie-Mellon University, Pittsburgh, PA, May 2001.
[33]
R. O'Callahan and D. Jackson. Lackwit: A program understanding tool based on type inference. In ICSE, pages 338--348, May 1997.
[34]
A. Ohori and P. Buneman. Static type inference for parametric classes. In OOPSLA, pages 445--456, Oct. 1989.
[35]
J. Palsberg and M. I. Schwartzbach. Object-oriented type inference. In OOPSLA, pages 146--161, Oct. 1991.
[36]
J. Palsberg and M. I. Schwartzbach. Object-Oriented Type Systems. John Wiley and Sons, 1994.
[37]
P. Plauger, A. A. Stepanov, M. Lee, and D. R. Musser. The C ++ Standard Template Library. Prentice Hall PTR, 2000.
[38]
J. Plevyak and A. A. Chien. Precise concrete type inference for object-oriented languages. In OOPSLA, pages 324--340, Oct. 1994.
[39]
M. Siff and T. Reps. Program generalization for software reuse: From C to C++. In FSE, pages 135--146, Oct. 1996.
[40]
B. Stroustrup. The Design and Evolution of C ++. Addison-Wesley, Reading, Massachusetts, 1994.
[41]
B. Stroustrup. The C ++ Programming Language. Addison-Wesley, Boston, MA, special edition, 2000.
[42]
F. Tip, R. Fuhrer, J. Dolby, and A. Kiežun. Refactoring techniques for migrating applications to generic Java container classes. IBM Research Report RC 23238, IBM T.J. Watson Research Center, Yorktown Heights, NY, USA, June 2, 2004.
[43]
F. Tip, A. Kiežun, and D. Bäumer. Refactoring for generalization using type constraints. In OOPSLA, pages 13--26, Nov. 2003.
[44]
F. Tip and J. Palsberg. Scalable propagation-based call graph construction algorithms. In OOPSLA, pages 281--293, Oct. 2000.
[45]
M. Torgersen, C. P. Hansen, E. Ernst, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. In SAC, pages 1289--1296, Mar. 2004.
[46]
R. Vallée-Rai, L. Hendren, V. Sundaresan, P. Lam, E. Gagnon, and P. Co. Soot - a Java bytecode optimization framework. In CASCON, pages 125--135, Nov. 1999.
[47]
D. von Dincklage and A. Diwan. Converting Java classes to use generics. In OOPSLA, Oct. 2004.
[48]
T. Wang and S. Smith. Precise constraint-based type inference for Java. In ECOOP, pages 99--117, June 2001.
[49]
D. Yu, A. Kennedy, and D. Syme. Formalization of generics for the.NET common language runtime. In POPL, pages 39--51, Jan. 2004.

Cited By

View all
  • (2016)Towards improving interface modularity in legacy Java software through automated refactoringCompanion Proceedings of the 15th International Conference on Modularity10.1145/2892664.2892681(104-106)Online publication date: 14-Mar-2016
  • (2014)An Evaluation Framework and Comparative Analysis of the Widely Used First Programming LanguagesPLoS ONE10.1371/journal.pone.00889419:2(e88941)Online publication date: 24-Feb-2014
  • (2013)Sinfer: Inferring information flow lattices for checking self-stabilization2013 IEEE 24th International Symposium on Software Reliability Engineering (ISSRE)10.1109/ISSRE.2013.6698925(258-267)Online publication date: Nov-2013
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
October 2004
462 pages
ISBN:1581138318
DOI:10.1145/1028976
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 39, Issue 10
    OOPSLA '04
    October 2004
    448 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1035292
    Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 2004

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. JSR-14
  2. Java 1.5
  3. Java 5
  4. generic types
  5. instantiation types
  6. parameterized types
  7. parametric polymorphism
  8. raw types
  9. type inference

Qualifiers

  • Article

Conference

OOPSLA04

Acceptance Rates

Overall Acceptance Rate 268 of 1,244 submissions, 22%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)9
  • Downloads (Last 6 weeks)0
Reflects downloads up to 15 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2016)Towards improving interface modularity in legacy Java software through automated refactoringCompanion Proceedings of the 15th International Conference on Modularity10.1145/2892664.2892681(104-106)Online publication date: 14-Mar-2016
  • (2014)An Evaluation Framework and Comparative Analysis of the Widely Used First Programming LanguagesPLoS ONE10.1371/journal.pone.00889419:2(e88941)Online publication date: 24-Feb-2014
  • (2013)Sinfer: Inferring information flow lattices for checking self-stabilization2013 IEEE 24th International Symposium on Software Reliability Engineering (ISSRE)10.1109/ISSRE.2013.6698925(258-267)Online publication date: Nov-2013
  • (2013)Adoption and use of Java genericsEmpirical Software Engineering10.1007/s10664-012-9236-618:6(1047-1089)Online publication date: 1-Dec-2013
  • (2012)Automated repair of HTML generation errors in PHP applications using string constraint solvingProceedings of the 34th International Conference on Software Engineering10.5555/2337223.2337257(277-287)Online publication date: 2-Jun-2012
  • (2012)A Comprehensive Approach to Naming and Accessibility in Refactoring Java ProgramsIEEE Transactions on Software Engineering10.1109/TSE.2012.1338:6(1233-1257)Online publication date: 1-Nov-2012
  • (2012)Automated repair of HTML generation errors in PHP applications using string constraint solving2012 34th International Conference on Software Engineering (ICSE)10.1109/ICSE.2012.6227186(277-287)Online publication date: Jun-2012
  • (2012)Inference and checking of object ownershipProceedings of the 26th European conference on Object-Oriented Programming10.1007/978-3-642-31057-7_9(181-206)Online publication date: 11-Jun-2012
  • (2012)Constraint-Based refactoring with foresightProceedings of the 26th European conference on Object-Oriented Programming10.1007/978-3-642-31057-7_24(535-559)Online publication date: 11-Jun-2012
  • (2011)A refactoring constraint language and its application to eiffelProceedings of the 25th European conference on Object-oriented programming10.5555/2032497.2032516(255-280)Online publication date: 25-Jul-2011
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media