ACM Home Page
Please provide us with feedback. Feedback
Java type inference is broken: can we fix it?
Full text PdfPdf (346 KB)
Source
Conference on Object Oriented Programming Systems Languages and Applications archive
Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications table of contents
Nashville, TN, USA
SESSION: Type inference and tools table of contents
Pages 505-524  
Year of Publication: 2008
ISBN:978-1-60558-215-3
Also published in ...
Authors
Daniel Smith  Rice University, Houston, TX, USA
Robert Cartwright  Rice University, Houston, TX, USA
Sponsors
SIGPLAN: ACM Special Interest Group on Programming Languages
ACM: Association for Computing Machinery
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 23,   Downloads (12 Months): 172,   Citation Count: 1
Additional Information:

abstract   references   cited by   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/1449764.1449804
What is a DOI?

ABSTRACT

Java 5, the most recent major update to the Java Programming Language, introduced a number of sophisticated features, including a major extension to the type system. While the technical details of these new features are complex, much of this complexity is hidden from the typical Java developer by an ambitious type inference mechanism. Unfortunately, the extensions to the Java 5 type system were so novel that their technical details had not yet been thoroughly investigated in the research literature. As a result, the Java 5 compiler includes a pragmatic but flawed type inference algorithm that is, by design, neither sound nor locally complete. The language specification points out that neither of these failures is catastrophic: the correctness of potentially-unsound results must be verified during type checking; and incompleteness can usually be worked around by manually providing the method type parameter bindings for a given call site.

This paper dissects the type inference algorithm of Java 5 and proposes a signficant revision that is sound and able to calculate correct results where the Java 5 algorithm fails. The new algorithm is locally complete with the exception of a difficult corner case. Moreover, the new algorithm demonstrates that several arbitrary restrictions in the Java type system---most notably the ban on lower-bounded type parameter declarations and the limited expressibility of intersection types---are unnecessary. We hope that this work will spur the evolution of a more coherent, more comprehensive generic type system for Java.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

1
 
2
Luca Cardelli. An Implementation of F:. Research report 97, DEC Systems Research Center, 1993.
 
3
4
 
5
 
6
Atsushi Igarashi & Hideshi Nagira. Union Types for Object-Oriented Programming. Journal of Object Technology, vol. 6, no. 2, February 2007.
 
7
Andrew J. Kennedy & Benjamin C. Pierce. On Decidability of Nominal Subtyping with Variance. FOOL/WOOD, 2007.
 
8
Benjamin C. Pierce & David N. Turner. Local Type Argument Synthesis with Bounded Quantification. Technical report TR495, Indiana University, 1997.
9
 
10
Daniel Smith. Completing the Java Type System. Master's thesis, Rice University, 2007.
 
11
Kresten Krab Thorup & Mads Torgersen. Unifying Genericity: Combining the Benefits of Virtual Types and Parameterized Classes. Lecture Notes in Computer Science, 1999.
12
 
13
Mads Torgersen, Erik Ernst, & Christian Plesner Hansen. Wild FJ. FOOL, 2005.
 
14
DrJava IDE. http://drjava.org.
 
15
Java Community Process. http://jcp.org.
 
16
"Type variables should have lower/super bounds." Java Request for Enhancement. http://bugs.sun.com/view_bug.do?bug_id=5052956.
 
17
"Please introduce a name for the "null' type." Java Request for Enhancement. http://bugs.sun.com/view_bug.do?bug_id=5060259.
 
18
"Multiply-bounded reference type expressions." Java Request for Enhancement. http://bugs.sun.com/view_bug.do?bug_id=6350706.


Collaborative Colleagues:
Daniel Smith: colleagues
Robert Cartwright: colleagues