Nothing Special   »   [go: up one dir, main page]

skip to main content
article

Parametric polymorphism for Java: is there any hope in sight?

Published: 01 December 2004 Publication History

Abstract

In spite of years of research toward a solution for the problem of extending Java with parametric polymorphism (genericity) the officially accepted solution already in its beta release allows violation of the Java type system and turns a type safe language into an unsafe one. The run-time type information in this release is incorrect which leads to major problems for the programmers relying on the Java reflective capabilities. We show that there are two basic reasons for these problems. The first one is that the idiom underlying this solution is provably incorrect. The second one is that the problem of extending Java with parametric polymorphism does not have a correct solution unless the Java Virtual Machine is extended to handle it properly. This paper elaborates the subtleties required by a correct implementation technique that includes representation of parametric classes in the standard Java class file format, representation of the instantiated parametric class objects, extensions of the Java Core Reflection to report type information about (instantiated) parametric classes, and the loading techniques required by this solution for extending Java with generics. Previous solutions for this problem are analyzed as well.

References

[1]
Agesen, O., Freund, S. N. and Mitchell, J. C. Adding Type Parameterization to the Java Language. ACM Special Interest Group on Programming Languages 1997, 49--65.]]
[2]
Alagić, S. and Nguyen, T. Parametric polymorphism and orthogonal persistence. Proceedings of the ECOOP 2000 Symposium on Objects and Databases, Lecture Notes in Computer Science 1944, 2000, 32--46.]]
[3]
Alagić, S. Solórzano, J. and Gitchell, D. Orthogonal to the Java imperative. Proceedings of ECOOP 1998, Lecture Notes in Computer Science 1445, 212--233.]]
[4]
Allen, E. A Guide to Generics in the Java Tiger version and the JSR-14 prototype compiler. IBM Developer Works, February 2003. http://www-106.ibm.com/developerworks/java/library/jdjc02113.html]]
[5]
Allen, E., Overcoming the Limitations in the JSR-14 Compiler. IBM Developer Works, April 2003 http://www.106.ibm.com/developerworks/java/library/j-djc04093.html]]
[6]
Allen, E., Some Limitations of Generics in the JSR-14 Prototype Compiler. IBM Developer Works, March 2003 http://www-106.ibm.com/developerworks/java/library/j-djc03113.html]]
[7]
Allen, E., Bannet, J., Cartwright, R. A First-Class Approach to Genericity. Proceedings of OOPSLA 2003, 96--114]]
[8]
Allen, E., Cartwright, R., Stoler, B. Efficient Implementation of Run-time Generic Types for Java. Generic Programming 2002, 207--236]]
[9]
Bracha, G. and the Expert Group. Java Specification Request 14: Add Generic Types to the JavaTM Programming Language. http://jcp.org/jsr/detail/14.prt]]
[10]
Bracha, G., Cohen, N., Kemper, C., Marx, S., Odersky, M., Panitz, S. E., Stoutamire, D., Thorup, K. and Wadler, P. Adding Generics to the Java Programming Language: Participant Draft Specification. April 27, 2001. http://jcp.org/aboutJava/communityprocess/review/jsr014/index.html]]
[11]
Bracha, G., Odersky, M., Stoutamire, D. and Wadler, P. Making the future safe for the past: Adding Genericity for the Java Programming Language. Proceedings of OOPSLA 1998, 183--200.]]
[12]
Cartwright, R. and Steele Jr., G. L. Compatible Genericity with Runtime Types for the Java Programming Language. Proceedings of the OOPSLA 1998, 201--218.]]
[13]
Close, S., Using Java Generics. Java Developers Journal. November 2003, 32--37, 60]]
[14]
Day, M., Gruber, R., Liskov, B. and Myers, A. C. Subtypes vs. Where Clauses: Constraining Parametric Polymorphism. Proceedings of OOPSLA (Austin TX, October 1995), 156--168.]]
[15]
Gosling, J., Joy, B., Steele, G. and Bracha, G. The Java Language Specification, Second Edition. The Java Series. Addison-Wesley, 2000.]]
[16]
Kennedy, A. and Syme, D. Design and Implementation of Generics for the .NET Common Language Runtime. Proceedings of PLDI, 1--12, ACM 2001.]]
[17]
Liang, S. and Bracha, G. Dynamic Class Loading in the Java Virtual Machine. ACM SIGPLAN Notices, Proceedings of OOPSLA 1998, 36--44.]]
[18]
Lindholm, T. and Yellin, F. The Java Virtual Machine Specification, Second Edition. The Java Series. Addison-Wesley, 2000.]]
[19]
Meyers, A. C., Bank, J. A. and Liskov, B. Parameterized Types for Java. Proceedings of the 24th ACM Symposium on Principles of Programming Languages (Paris, France, January 1997), 132--145.]]
[20]
Odersky, M. and Wadler, P. Pizza into Java: Translating theory into practice. Proceedings of the 24th ACM Symposium on Principles of Programming Languages (Paris, France, January 1997), 146--159.]]
[21]
Solórzano, J. and Alagić, S. Parametric polymorphism for Java: A reflective solution, Proceedings of OOPSLA 1998, 216--225.]]
[22]
Viroli, M. From FGJ to Java according to LM translator, Workshop on Formal Techniques for Java Programs, ECOOP 2001.]]
[23]
Viroli, M. Parametric Polymorphism in Java: an Efficient Implementation for Parametric Methods. Proceedings of the 2001 ACM symposium on Applied Computing, 2001, 610--619.]]
[24]
Viroli, M. and Natali, A. Parametric Polymorphism in Java: an Approach to Translation Based on Reflective Features. Proceedings of OOPSLA 2000, 146--160.]]

Cited By

View all
  • (2019)The Java 5 generics compromise orthogonality to keep compatibilityJournal of Systems and Software10.1016/j.jss.2008.04.00881:11(2069-2078)Online publication date: 2-Jan-2019
  • (2008)Genericity in JavaThe VLDB Journal — The International Journal on Very Large Data Bases10.1007/s00778-006-0042-x17:4(847-878)Online publication date: 1-Jul-2008
  1. Parametric polymorphism for Java: is there any hope in sight?

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 39, Issue 12
    December 2004
    116 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1052883
    Issue’s Table of Contents

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 December 2004
    Published in SIGPLAN Volume 39, Issue 12

    Check for updates

    Author Tags

    1. Java core reflection
    2. Java virtual machine
    3. class files
    4. class objects
    5. generics
    6. loading
    7. parametric polymorphism

    Qualifiers

    • Article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)2
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 25 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2019)The Java 5 generics compromise orthogonality to keep compatibilityJournal of Systems and Software10.1016/j.jss.2008.04.00881:11(2069-2078)Online publication date: 2-Jan-2019
    • (2008)Genericity in JavaThe VLDB Journal — The International Journal on Very Large Data Bases10.1007/s00778-006-0042-x17:4(847-878)Online publication date: 1-Jul-2008

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media