skip to main content
10.1145/967900.968162acmconferencesArticle/Chapter ViewAbstractPublication PagessacConference Proceedingsconference-collections
Article

Adding wildcards to the Java programming language

Published:14 March 2004Publication History

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. K. Bruce. Subtyping is not a good match for object-oriented programming languages. In ECOOP97 {11}.]]Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. R. Cartwright and G. L. Steele. Compatible genericity with runtime-types for the Java programming language. In OOPSLA98 {26}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. ECMA. C# language specification. http://www.ecma-international.org/publications/standards/Ecma-334.htm, 2002.]]Google ScholarGoogle Scholar
  11. ECOOP97. European Conference on Object-Oriented Programming, Jyväskylä, Finland, June 1997. LNCS 1241, Springer Verlag. Mehmet Akşit and Satoshi Matsuoka, editors.]]Google ScholarGoogle Scholar
  12. ECOOP99. European Conference on Object-Oriented Programming, Lisbon, Portugal, June 1999. LNCS 1628, Springer Verlag. Rachid Guerraoui, editor.]]Google ScholarGoogle Scholar
  13. M. A. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. A. Igarashi and B. C. Pierce. Foundations for virtual types. In ECOOP99 {12}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. D. MacQueen. SML '97 conversion guide. http://www.smlnj.org/doc/Conversion/index.html, 2003.]]Google ScholarGoogle Scholar
  20. O. L. Madsen, B. Môller-Pedersen, and K. Nygaard. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley, 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. R. Milner, M. Tofte, R. W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. J. C. Mitchell and G. D. Plotkin. Abstract types have existential types. ACM Transactions on Programming Languages and Systems, 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. OOPSLA98. Object Oriented Programming: Systems, Languages and Applications, Vancouver, BC, Oct. 1998. ACM Press. Craig Chambers, editor.]]Google ScholarGoogle Scholar
  27. C. V. Russo. First-class structures for standard ML. Lecture Notes in Computer Science, 1782:336++, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. D. Stoutamire and S. Omohundro. The Sather 1.1 specification. Technical Report TR-96-012, International Computer Science Institute, Berkeley, CA, Aug. 1996.]]Google ScholarGoogle Scholar
  29. K. K. Thorup. Genericity in Java with virtual types. In ECOOP97 {11}, pages 444--471.]]Google ScholarGoogle Scholar
  30. K. K. Thorup and M. Torgersen. Unifying genericity. In ECOOP99 {12}, pages 186--204.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle Scholar
  32. M. Torgersen. Unifying Abstractions. PhD thesis, Computer Science Department, University of Aarhus, bogade 34, DK-8200 rhus N, Sept. 2001.]]Google ScholarGoogle Scholar

Index Terms

  1. Adding wildcards to the Java programming language

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      SAC '04: Proceedings of the 2004 ACM symposium on Applied computing
      March 2004
      1733 pages
      ISBN:1581138121
      DOI:10.1145/967900

      Copyright © 2004 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 14 March 2004

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      Overall Acceptance Rate1,650of6,669submissions,25%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader