Previous article

Next article

Adding Wildcards to the Java Programming Language

Mads Torgersen, University of Aarhus, Denmark
Erik Ernst, University of Aarhus, Denmark
Christian Plesner Hansen, OOVM, Aarhus, Denmark
Peter von der Ahé, Sun Microsystems, Inc., California, USA
Gilad Bracha, Sun Microsystems, Inc., California, USA
Neal Gafter, Google Inc., California, USA

space PDF Icon
PDF Version


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 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 that parametric polymorphism introduces. Wildcards are implemented as part of the addition of generics to the JavaTM programming language, and is thus 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 newest release, and some of the examples in this paper are taken from these APIs.

Note: Due to the typographical sophistication of this article, no HTML version is available. Please use the PDF version.


About the authors

Peter von der Ahé, M.Sc. was until recently at the University of Aarhus, Denmark. He now maintains javac at Sun Microsystems. Peter’s home page is at http://www.ahe.dk/peter/.

Gilad Bracha, Ph.D. is a Computational Theologist at Sun Microsystems. He is co-author and maintainer of the Java language specification. His home page is at http://bracha.org/.

Erik Ernst, Ph.D. is a research associate professor at the University of Aarhus, Denmark. His home page is at http://www.daimi.au.dk/~eernst/.

Neal Gafter, Ph.D. works at Google Inc. He maintained javac at Sun Microsystems, Inc., until recently. His home page is at http://www.gafter.com/~neal/.

Christian Plesner Hansen, M.Sc. just graduated from the University of Aarhus, Denmark, and is now employed at OOVM a/s, Aarhus, Denmark. His home page is at http://www.daimi.au.dk/~plesner/.

Mads Torgersen, Ph.D. works as a research assistant professor at the University of Aarhus, Denmark. His home page is at http://www.daimi.au.dk/~madst/.

Moreover, the authors constitute the team which specified and implemented wildcards in the Java programming language.

Cite this article as follows: Mads Torgersen, Erik Ernst, Christian Plesner Hansen, Peter von der Ahé, Gilad Bracha, Neal Gafter: ”Adding Wildcards to the Java Programming Language”, in Journal of Object Technology, vol. 3, no. 11, December 2004, Special issue: OOPS track at SAC 2004, Nicosia/Cyprus, pp. 97–116, http://www.jot.fm/issues/issue_2004_12/article5

Previous article

Next article