Academia.eduAcademia.edu

Outline

Making the future safe for the past

1998, ACM SIGPLAN Notices

Abstract

We present GJ, a design that extends the Java programming language with generic types and methods. These are both explained and implemented by translation into the unextended language. The translation closely mimics the way generics are emulated by programmers: it erases all type parameters, maps type variables to their bounds, and inserts casts where needed. Some subtleties of the translation are caused by the handling of overriding.GJ increases expressiveness and safety: code utilizing generic libraries is no longer buried under a plethora of casts, and the corresponding casts inserted by the translation are guaranteed to not fail.GJ is designed to be fully backwards compatible with the current Java language, which simplifies the transition from non-generic to generic programming. In particular, one can retrofit existing library classes with generic interfaces without changing their code.An implementation of GJ has been written in GJ, and is freely available on the web.

References (27)

  1. Ole Agesen, Stephen Freund, and John C. Mitchell. Adding parameterized types to Java. Confer- ence on Object-Oriented Programming, Systems, Lan- guages and Applications, pages 215-230, 1997.
  2. Alexander Aiken and Edward L. Wimmers. Type inclusion constraints and type inference. Functional Programming Languages and Computer Architecture, pages 31-41, ACM, 1993.
  3. Gilad Bracha and David Griswold. Strongtalk: Typechecking Smalltalk in a production environment. In Conference on Object-Oriented Programming, Sys- tems, Languages and Applications, pages 215-230, 1993.
  4. Kim B. Bruce, Martin Odersky, and Philip Wadler. A statically safe alternative to virtual types. European Conference on Object-Oriented Program- ming, July 1998. (An earlier version was presented at 5th Workshop on Foundations of Object-Oriented Languages, January 1998.)
  5. Peter Canning, William Cook, Walter Hill, Walter Olthoff, and John C. Mitchell. F- bounded polymorphism for object-oriented program- ming. Functional Programming Languages and Com- puter Architecture, pages 273-280, ACM, 1989.
  6. Corky Cartwright and Guy Steele. Compatible genericity with run-time types for the Java pro- gramming language. Conference on Object-Oriented Programming, Systems, Languages and Applications, 1998.
  7. EST951 Jonathan Eifrig, Scott Smith, and Valery Trifonov. Sound polymorphic type inference for objects. Conjer- ence on Object-Oriented Programming, Systems, Lan- guages and Applications, pages 169-184, 1995.
  8. Erich G amma, Richard Helm, Ralph Johnson and John Vlissides. Design Patterns : Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994.
  9. A. Goldberg and D. Robson. Smalltalk-80: the Lan- guage and Its Implementation. Addison-Wesley, 1983.
  10. Martin Odersky. The GJ compiler. Available from www.cis.unisa.edu.au/-pizza/gj wwwipd.ira.uka.de/"pizza/gj www.math.luc.edu/pizza/gj www.cs.bell-labs.com/"wadler/pizza/gj
  11. Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. GJ: the Java programming lan- guage with type parameters. Manuscript, 1998. Avail- able at the GJ web site.
  12. Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. GJ Specification. Manuscript, 1998. Available at the GJ web site.
  13. James Gosling, Bill Joy, and Guy Steele. The Java language specification.
  14. Java Series, Sun Microsystems, ISBN O-201-63451-1, 1996.
  15. Tim Lindholm and Frank Yellin. The Java Virtual Machine specification.
  16. Java Series, Sun Microsystems, ISBN 0-201-63452-X, 1996.
  17. Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sci- ences, 17:348-375, 1978.
  18. Andrew C. Myers, Joseph A. Bank, and Barbara Liskov. Parameterized types for Java. Symposium on Principles of Programming Languages, pages 132-145, ACM, 1997.
  19. OR981 Martin Odersky and Enno Runne. Measuring the cost of parameterized types in Java. Research Report CIS-98-004, Advanced Computing Research Centre, University of South Australia, January 1998.
  20. Martin Odersky and Philip Wadler. Pizza into Java: Translating theory into practice. Symposs'um on Principles of Programming Languages, pages 146-159, ACM, 1997.
  21. Benjamin C. Pierce and David N. Turner. Local Type Inference. Symposium on Principles of Program- ming Languages, pages 2522265, ACM, 1998.
  22. Paul Roe and Clemens Szyperski. Lightweight Para- metric Polymorphism for Oberon. Proceedings Joint Modular Languages Conference, Johannes Kepler Uni- versity Linz SchloB Hagenberg Austria, March, 1997 http://www.fit.qut.edu.au/"szypersk/Gardens/
  23. Kresten Krab Thorup. Genericity in Java with vir- tual types. European Conference on Object-Oriented
  24. Programming, pages 444-471, LNCS 1241, Springer- Verlag, 1997.
  25. Mads Togersen. Virtual types are statically safe. 5th Workshop on Foundations of Object-Oriented Lan- guages, January 1998.
  26. Kresten Krab Thorup and Mads Togersen. Struc- tural virtual types. Informal session on types for Java, 5th Workshop on Foundations of Object-Oriented Lan- guages, January 1998.
  27. A. Wright, Simple imperative polymorphism, Lisp and Symbolic Computation, 8:343-355, 1995.