Advertisement

Precise Constraint-Based Type Inference for Java

  • Tiejun Wang
  • Scott F. Smith
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2072)

Abstract

Precise type information is invaluable for analysis and optimization of object-oriented programs. Some forms of polymorphism found in object-oriented languages pose significant difficulty for type inference, in particular data polymorphism. Agesen’s Cartesian Product Algorithm (CPA) can analyze programs with parametric polymorphism in a reasonably precise and efficient manner, but CPAl oses precision for programs with data polymorphism. This paper presents a precise constraintbased type inference system for Java. It uses Data-Polymorphic CPA (DCPA), a novel constraint-based type inference algorithm which extends CPA with the ability to accurately and efficiently analyze data polymorphic programs. The system is implemented for the full Java language, and is used to statically verify the correctness of Java downcasts. Benchmark results are given which show that DCPAi s significantly more accurate than CPAan d the efficiency of DCPAis close to CPA.

Keywords

Object Type Type Scheme Type Inference Method Invocation Data Polymorphism 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [AFFS98]
    Alexander Aiken, Manuel Fhndrich, Jeffrey S. Foster, and Zhendong Su. Partial online cycle elimination in inclusion constraint graphs. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1998.Google Scholar
  2. [Age95]
    Ole Agesen. The cartesian product algorithm. In Proceedings ECOOP’95, volume 952 of Lecture notes in Computer Science, 1995.Google Scholar
  3. [Age96]
    Ole Agesen. Concrete Type Inference: Delivering Object-Oriented Applications. PhD thesis, Stanford University, 1996. Available as Sun Labs Technical Report SMLI TR-96-52.Google Scholar
  4. [AW93]
    A. Aiken and E. L. Wimmers. Type inclusion constraints and type inference. In Proceedings of the International Conference on Functional Programming Languages and Computer Architecture, pages 31–41, 1993.Google Scholar
  5. [Cal99]
    Robert O’ Callahan. Optimizing a solver of polymorphism constraints: SEMI. Technical Report CMU-CS-99-136, CMU, June 1999.Google Scholar
  6. [Dug99]
    Dominic Duggan. Modular type-based reverse engineering of parameterized types in java code. In ACM SIGPLAN Symposium on Object-Oriented Programming: Systems, Languages and Applications (OOPSLA), 1999.Google Scholar
  7. [EST95]
    Jonathan Eifrig, Scott Smith, and Çois Pottier. A framework for type inference with subtyping. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP’98), September 1998.Google Scholar
  8. [PP98]
    Jens Palsberg and Christina Pavlopoulou. From polyvariant flow information to intersection and union types. In POPL, 1998.Google Scholar
  9. [Shi91]
    Olin Shivers. Control-Flow Analysis of Higher-Order Languages. PhD thesis, Carnegie-Mellon University, 1991. Available as CMU Technical Report CMU-CS-91-145.Google Scholar
  10. [SHR+00]
    V. Sundaresan, L. Hendren, C. Razafimahefa, R. Valee-Rai, P. Lam, E. Gagnon, and C. Godin. Practical virtual method call resolution for java. In ACM Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), 2000.Google Scholar
  11. [SW00]
    Scott Smith and Tiejun Wang. Polyvariant flow analysis with constrained types. In Gert Smolka, editor, Proceedings of the 2000 European Symposium on Programming (ESOP’00), volume 1782 of Lecture Notes in Computer Science, pages 382–396. Springer Verlag, March 2000.Google Scholar
  12. [TLSS99]
    F. Tip, C. Laffra, P. Sweeney, and D. Streeter. Practical experience with an application extractor for java. In ACM Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), 1999.Google Scholar
  13. [TP00]
    F. Tip and J. Palsberg. Scalable propagation-based call graph construction. In ACM Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), 2000.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2001

Authors and Affiliations

  • Tiejun Wang
    • 1
  • Scott F. Smith
    • 1
  1. 1.Department of Computer ScienceThe Johns Hopkins University BaltimoreMDUSA

Personalised recommendations