Abstract
Wildcards have become an important part of Java's type system since their introduction 7 years ago. Yet there are still many open problems with Java's wildcards. For example, there are no known sound and complete algorithms for subtyping (and consequently type checking) Java wildcards, and in fact subtyping is suspected to be undecidable because wildcards are a form of bounded existential types. Furthermore, some Java types with wildcards have no joins, making inference of type arguments for generic methods particularly difficult. Although there has been progress on these fronts, we have identified significant shortcomings of the current state of the art, along with new problems that have not been addressed.
In this paper, we illustrate how these shortcomings reflect the subtle complexity of the problem domain, and then present major improvements to the current algorithms for wildcards by making slight restrictions on the usage of wildcards. Our survey of existing Java programs suggests that realistic code should already satisfy our restrictions without any modifications. We present a simple algorithm for subtyping which is both sound and complete with our restrictions, an algorithm for lazily joining types with wildcards which addresses some of the shortcomings of prior work, and techniques for improving the Java type system as a whole. Lastly, we describe various extensions to wildcards that would be compatible with our algorithms.
- Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA, 1998. Google Scholar
Digital Library
- Nicholas Cameron and Sophia Drossopoulou. On subtyping, wildcards, and existential types. In FTfJP, 2009. Google Scholar
Digital Library
- Nicholas Cameron, Sophia Drossopoulou, and Erik Ernst. A model for Java with wildcards. In ECOOP, 2008. Google Scholar
Digital Library
- Peter Canning, William Cook, Walter Hill, Walter Olthoff, and John C. Mitchell. \hboxF-bounded polymorphism for object-oriented programming. In FPCA, 1989. Google Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steel, and Gilad Bracha. The Java#8482; Language Specification. Addison-Wesley Professional, third edition, June 2005. Google Scholar
Digital Library
- Atsushi Igarashi and Mirko Viroli. On variance-based subtyping for parametric types. In ECOOP, 2002. Google Scholar
Digital Library
- Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17:1--82, January 2007. Google Scholar
Digital Library
- Andrew Kennedy and Benjamin Pierce. On decidability of nominal subtyping with variance. In FOOL, 2007.Google Scholar
- Daan Leijen. HMF: Simple type inference for first-class polymorphism. In ICFP, 2008. Google Scholar
Digital Library
- Martin Odersky and Konstantin Läufer. Putting type annotations to work. In POPL, 1996. Google Scholar
Digital Library
- Gordon D. Plotkin. A note on inductive generalization. In Machine Intelligence, volume 5, pages 153--163. Edinburgh University Press, 1969.Google Scholar
- John C. Reynolds. Transformational systems and the algebraic structure of atomic formulas. In Machine Intelligence, volume 5, pages 135--151. Edinburgh University Press, 1969.Google Scholar
- Daniel Smith and Robert Cartwright. Java type inference is broken: Can we fix it? In OOPSLA, 2008. Google Scholar
Digital Library
- Alexander J. Summers, Nicholas Cameron, Mariangiola Dezani-Ciancaglini, and Sophia Drossopoulou. Towards a semantic model for Java wildcards. In FTfJP, 2010. Google Scholar
Digital Library
- Ross Tate, Alan Leung, and Sorin Lerner. Taming wildcards in Java's type system. Technical report, University of California, San Diego, March 2011.Google Scholar
- Kresten Krab Thorup and Mads Torgersen. Unifying genericity - combining the benefits of virtual types and parameterized classes. In ECOOP, 1999. Google Scholar
Digital Library
- Mads Torgersen, Erik Ernst, and Christian Plesner Hansen. Wild FJ. In FOOL, 2005.Google Scholar
- Mads Torgersen, Christian Plesner Hansen, Erik Ernst, Peter von der Ahé, Gilad Bracha, and Neal Gafter. Adding wildcards to the Java programming language. In SAC, 2004. Google Scholar
Digital Library
- Mirko Viroli. On the recursive generation of parametric types. Technical Report DEIS-LIA-00-002, Università di Bologna, September 2000.Google Scholar
- Stefan Wehr and Peter Thiemann. On the decidability of subtyping with bounded existential types. In APLAS, 2009. Google Scholar
Digital Library
Index Terms
Taming wildcards in Java's type system
Recommendations
Taming wildcards in Java's type system
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and ImplementationWildcards have become an important part of Java's type system since their introduction 7 years ago. Yet there are still many open problems with Java's wildcards. For example, there are no known sound and complete algorithms for subtyping (and ...
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#) ...
Java type inference is broken: can we fix it?
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 ...







Comments