ABSTRACT
This paper describes wildcards, a new language construct designed to increase the flexibility of object-oriented type systems with parameterized classes. Based on the notion of use-site variance, wildcards provide a type safe abstraction over different instantiations of parameterized classes, by using '?' to denote unspecified type arguments. Thus they essentially unify the distinct families of classes often introduced by parametric polymorphism. Wildcards are implemented as part of the upcoming addition of generics to the Java™ programming language, and will thus be deployed world-wide as part of the reference implementation of the Java compiler javac available from Sun Microsystems, Inc. By providing a richer type system, wildcards allow for an improved type inference scheme for polymorphic method calls. Moreover, by means of a novel notion of wildcard capture, polymorphic methods can be used to give symbolic names to unspecified types, in a manner similar to the "open" construct known from existential types. Wildcards show up in numerous places in the Java Platform APIs of the upcoming release, and some of the examples in this paper are taken from these APIs.
- O. Agesen, S. N. Freund, and J. C. Mitchell. Adding type parameterization to the java programming language. In Object Oriented Programming: Systems, Languages and Applications, Atlanta, Georgia, Oct. 1997. OOPSLA97, ACM Press. Toby Bloom, editor.]] Google ScholarDigital Library
- P. America and F. van der Linden. A parallel object-oriented language with inheritance and subtyping. In Object Oriented Programming: Systems, Languages and Applications/European Conference on Object-Oriented Programming, pages 161--168, Ottawa, Canada, Oct. 1990. OOPSLA/ECOOP90, ACM Press. Norman K. Meyrowitz, editor.]] Google ScholarDigital Library
- G. Bracha and D. Griswold. Strongtalk: Typechecking smalltalk in a production environment. In Object Oriented Programming: Systems, Languages and Applications, Washington DC, Oct. 1993. OOPSLA93, ACM Press. Andreas Paepcke, editor.]] Google ScholarDigital Library
- G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the java programming language. In OOPSLA98 {26}.]] Google ScholarDigital Library
- K. Bruce. Subtyping is not a good match for object-oriented programming languages. In ECOOP97 {11}.]]Google Scholar
- K. Bruce, M. Odersky, and P. Wadler. A statically safe alternative to virtual types. In European Conference on Object-Oriented Programming, Brussels, Belgium, July 1998. ECOOP98, LNCS 1445, Springer Verlag. Eric Jul, editor.]] Google ScholarDigital Library
- R. Cartwright and G. L. Steele. Compatible genericity with runtime-types for the Java programming language. In OOPSLA98 {26}.]] Google ScholarDigital Library
- W. Cook. A proposal for making Eiffel type-safe. In European Conference on Object-Oriented Programming, pages 57--70, Nottingham, England, July 1989. ECOOP89, Cambridge University Press. Stephen Cook, editor.]]Google ScholarDigital Library
- W. Cook, W. Hill, and P. Canning. Inheritance is not subtyping. In Principles of Programming Languages, pages 125--135, San Francisco, California, Jan. 1990. POPL90, ACM Press. Paul Hudak, editor.]] Google ScholarDigital Library
- ECMA. C# language specification. http://www.ecma-international.org/publications/standards/Ecma-334.htm, 2002.]]Google Scholar
- ECOOP97. European Conference on Object-Oriented Programming, Jyväskylä, Finland, June 1997. LNCS 1241, Springer Verlag. Mehmet Akşit and Satoshi Matsuoka, editors.]]Google Scholar
- ECOOP99. European Conference on Object-Oriented Programming, Lisbon, Portugal, June 1999. LNCS 1628, Springer Verlag. Rachid Guerraoui, editor.]]Google Scholar
- M. A. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley, 1990.]] Google ScholarDigital Library
- E. Ernst. gbeta - a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, University of Aarhus, Århus, Denmark, 1999.]]Google Scholar
- A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. In Object Oriented Programming: Systems, Languages and Applications, pages 132--146, Denver, Colorado, Oct. 1999. OOPSLA99, ACM Press. Linda Northrop, editor.]] Google ScholarDigital Library
- A. Igarashi and B. C. Pierce. Foundations for virtual types. In ECOOP99 {12}.]] Google ScholarDigital Library
- A. Igarashi and M. Viroli. On variance-based subtyping for parametric types. In European Conference on Object-Oriented Programming, pages 441--469, Málaga, Spain, June 2002. ECOOP02, LNCS 2374, Springer Verlag. Boris Magnusson, editor.]] Google ScholarDigital Library
- A. Kennedy and D. Syme. Design and implementation of generics for the .NET common language runtime. In C. Norris and J. J. B. Fenwick, editors, Proceedings of the ACM SIGPLAN '01 Conference on Programming Language Design and Implementation (PLDI-01), volume 36.5 of ACM SIGPLAN Notices, pages 1--12, N.Y., June 20--22 2001. ACMPress.]] Google ScholarDigital Library
- D. MacQueen. SML '97 conversion guide. http://www.smlnj.org/doc/Conversion/index.html, 2003.]]Google Scholar
- O. L. Madsen, B. Môller-Pedersen, and K. Nygaard. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley, 1993.]] Google ScholarDigital Library
- B. Meyer. Genericity versus inheritance. In Object Oriented Programming: Systems, Languages and Applications, pages 391--405, Portland, Oregon, Nov. 1986. OOPSLA86, ACM Press. Norman K. Meyrowitz, editor.]] Google ScholarDigital Library
- R. Milner, M. Tofte, R. W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, 1997.]] Google ScholarDigital Library
- J. C. Mitchell and G. D. Plotkin. Abstract types have existential types. ACM Transactions on Programming Languages and Systems, 1988.]] Google ScholarDigital Library
- A. Myers, J. Bank, and B. Liskov. Parameterized types for Java. In Conf. Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Paris, France, Jan. 1997. POPL97, ACM Press. Neil D. Jones, editor.]] Google ScholarDigital Library
- M. Odersky and P. Wadler. Pizza into Java: Translating theory into practice. In Conference Record of POPL '97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 146--159, Paris, France, 15--17 Jan. 1997.]] Google ScholarDigital Library
- OOPSLA98. Object Oriented Programming: Systems, Languages and Applications, Vancouver, BC, Oct. 1998. ACM Press. Craig Chambers, editor.]]Google Scholar
- C. V. Russo. First-class structures for standard ML. Lecture Notes in Computer Science, 1782:336++, 2000.]] Google ScholarDigital Library
- D. Stoutamire and S. Omohundro. The Sather 1.1 specification. Technical Report TR-96-012, International Computer Science Institute, Berkeley, CA, Aug. 1996.]]Google Scholar
- K. K. Thorup. Genericity in Java with virtual types. In ECOOP97 {11}, pages 444--471.]]Google Scholar
- K. K. Thorup and M. Torgersen. Unifying genericity. In ECOOP99 {12}, pages 186--204.]] Google ScholarDigital Library
- M. Torgersen. Virtual types are statically safe. In K. Bruce, editor, 5th Workshop on Foundations of Object-Oriented Languages, San Diego, CA, Jan. 1998.]]Google Scholar
- M. Torgersen. Unifying Abstractions. PhD thesis, Computer Science Department, University of Aarhus, bogade 34, DK-8200 rhus N, Sept. 2001.]]Google Scholar
Index Terms
- Adding wildcards to the Java programming language
Recommendations
Taming wildcards in Java's type system
PLDI '11Wildcards 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#) ...
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 ...
Comments