ABSTRACT
Java generics are compiled by-erasure: all clients reuse the same bytecode, with uses of the unknown type erased. C++ templates are compiled by-expansion: each type-instantiation of a template produces a different code definition. The two approaches offer trade-offs on multiple axes. We propose an extension of Java generics that allows by-expansion translation relative to selected type parameters only. This language design allows sophisticated users to get the best of both worlds at a fine granularity. Furthermore, our proposal is based on Java 8 Type Annotations (JSR 308) and the Checker Framework as an abstraction layer for controlling compilation without changes to the internals of a Java compiler.
- D. Ancona, G. Lagorio, and E. Zucca. Jam-Designing a Java Extension with Mixins. ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5):641--712, 2003. Google ScholarDigital Library
- R. Cardone, A. Brown, S. McDirmid, and C. Lin. Using Mixins to Build Flexible Widgets. In Proceedings of the 1st International Conference on Aspect-Oriented Software Development (AOSD), pages 76--85, New York, NY, USA, 2002. Google ScholarDigital Library
- W. Dietl, S. Dietzel, M. D. Ernst, K. Muşlu, and T. W. Schiller. Building and using Pluggable Type-Checkers. In Proceedings of the 33rd International Conference on Software Engineering, pages 681--690, 2011. Google ScholarDigital Library
- B. Eckel. Mixins: Something Else You Can't Do With Java Generics? http://www.artima.com/weblogs/viewpost.jsp?thread=132988, Oct. 2005.Google Scholar
- N. Gafter. Super Type Tokens. http://gafter.blogspot.gr/2006/12/super-type-tokens.html, Dec. 2006.Google Scholar
- T. Kamina and T. Tamai. McJava - A Design and Implementation of Java with Mixin-Types. In Proceedings of the Programming Languages and Systems: Second Asian Symposium, (APLAS), pages 4--6, Taipei, Taiwan, 2004.Google ScholarCross Ref
- M. Odersky. The Scala Language Specification, 2013.Google Scholar
- M. Odersky and P. Wadler. Pizza into Java: translating theory into practice. In Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of Programming languages (POPL), POPL '97, pages 146--159, New York, NY, USA, 1997. ACM. Google ScholarDigital Library
- M. M. Papi, M. Ali, T. L. Correa, Jr., J. H. Perkins, and M. D. Ernst. Practical Pluggable Types for Java. In Proceedings of the 2008 International Symposium on Software Testing and Analysis, ISSTA '08, pages 201--212, New York, NY, USA, 2008. ACM. Google ScholarDigital Library
- A. Sampson, W. Dietl, E. Fortuna, D. Gnanapragasam, L. Ceze, and D. Grossman. EnerJ: approximate data types for safe and general low-power computation. In Proceedings of the 32nd ACM SIGPLAN conference on Programming Language Design and Implementation (PLDI), pages 164--174, San Jose, California, USA, 2011. Google ScholarDigital Library
- J. Sasitorn and R. Cartwright. Efficient First-Class Generics on Stock Java Virtual Machines. In Proceedings of the 2006 ACM symposium on Applied computing, SAC '06, pages 1621--1628, New York, NY, USA, 2006. ACM. Google ScholarDigital Library
- Y. Smaragdakis and D. Batory. Implementing Layered Designs with Mixin Layers. In Proceedings of the 12th European Conference on Object-Oriented Programming (ECOOP), pages 550--570. Springer-Verlag LNCS 1445, 1998. Google ScholarDigital Library
- Y. Smaragdakis and D. Batory. Mixin-Based Programming in C++. In Generative and Component-Based Software Engineering Symposium (GCSE), pages 163--177. Springer-Verlag, LNCS 2177, 2000. Google ScholarDigital Library
- M. VanHilst and D. Notkin. Using C++ Templates to Implement Role-Based Designs. In JSSST International Symposium on Object Technologies for Advanced Software, pages 22--37. Springer Verlag, 1996. Google ScholarDigital Library
- M. VanHilst and D. Notkin. Using Role Components to Implement Collaboration-Based Designs. In Proceedings of the 1996 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA), pages 359--369, San Jose, California, USA, 1996. Google ScholarDigital Library
Index Terms
- Reified type parameters using Java annotations
Recommendations
Reified type parameters using Java annotations
GPCE '13Java generics are compiled by-erasure: all clients reuse the same bytecode, with uses of the unknown type erased. C++ templates are compiled by-expansion: each type-instantiation of a template produces a different code definition. The two approaches ...
Type qualifiers as composable language extensions
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesThis paper reformulates type qualifiers as language extensions that can be automatically and reliably composed. Type qualifiers annotate type expressions to introduce new subtyping relations and are powerful enough to detect many kinds of errors. Type ...
Safe instantiation in generic Java
Special issue: Principles and practices of programming in Java (PPPJ 2004)This paper introduces the "Safe Instantiation Principle", a new design criterion for evaluating extensions of Java that support generic types. The paper initially focuses on the GJ and NextGen formulations of Generic Java and the implications of safe ...
Comments