Abstract
Package Templates (PT) is a mechanism designed for writing reusable modules, called templates, each consisting of a set of classes that can be adapted to their use in a program through compile-time specialization. A template must be instantiated in a program before its classes can be used. The mechanism supports type-safe renaming, merging, type parameterization and refinement in the form of static additions and overrides that are orthogonal to the corresponding concepts of ordinary inheritance.
In this paper, we consider PT as an extension to Java, and a PT program will then consist of a number of Java packages and templates, where templates are instantiated in packages or other templates. Our aim and main contribution is to define the meaning of such a program, and to show that this definition is consistent. We first show this for a core subset of PT, C-PT, and define a set of source-to-source transformations for converting C-PT programs to plain Java programs using semantics we have described informally in previous papers. We can then define the meaning of a C-PT program in terms of the resulting Java program. Thus, we have to verify that the transformations will always convert a legal C-PT program to a legal Java program. Finally, we briefly discuss how this approach can be extended to full PT.
A main challenge is to preserve externally visible names (for classes, methods and fields), and at the same time prevent unwanted subsequent rebindings caused e.g. by over-load resolution in the Java compiler. Names that are bound to declarations in a template should not be rebound to different declarations by subsequent compositions or adaptions.
In addition to defining the runtime semantics of PT constructs in terms of their translation to Java, the transformation rules can also be seen as a high-level approach to how a compiler for this language might be implemented.
- Sven Apel, Christian Kästner, and Christian Lengauer. Feature featherweight java: a calculus for feature-oriented programming and stepwise refinement. In Proceedings of the 7th international conference on Generative programming and component engineering, GPCE '08, pages 101--112, New York, NY, USA, 2008. ACM. Google Scholar
Digital Library
- Sven Apel, Christian Kastner, and Christian Lengauer. Featurehouse: Language-independent, automated software composition. In Proc. 31st International Conference on Software Engineering, ICSE '09, pages 221--231, Washington, DC, USA, 2009. IEEE Computer Society. Google Scholar
Digital Library
- Sven Apel and Christian Lengauer. Superimposition: a language-independent approach to software composition. In Proc. 7th international conference on Software composition, SC'08, pages 20--35, Berlin, Heidelberg, 2008. Springer-Verlag. Google Scholar
Digital Library
- Eyvind W. Axelsen and Stein Krogdahl. Groovy package templates: supporting reuse and runtime adaption of class hierarchies. In DLS '09: Proc. 5th symp. Dyn. lang., pages 15--26, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- Eyvind W. Axelsen and Stein Krogdahl. Adaptable generic programming with required type specifications and package templates. In Proc. AOSD '12, AOSD '12, pages 83--94, New York, NY, USA, 2012. ACM. Google Scholar
Digital Library
- Eyvind W. Axelsen, Stein Krogdahl, and Birger Møller-Pedersen. Controlling dynamic module composition through an extensible meta-level API. In DLS 2010: Proc. 6th symp. Dyn. lang., New York, NY, USA, 2010. ACM. Google Scholar
Digital Library
- Eyvind W. Axelsen, Fredrik Sørensen, and Stein Krogdahl. A reusable observer pattern implementation using package templates. In ACP4IS '09, pages 37--42, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- Eyvind W. Axelsen, Fredrik Sørensen, Stein Krogdahl, and Birger Møller-Pedersen. Challenges in the design of the package template mechanism. Transactions on Aspect-Oriented Programming, 2012. To appear, available now from http://swat.project.ifi.uio.no/.Google Scholar
Cross Ref
- Don Batory. A Tutorial on Feature Oriented Programming and the AHEAD Tool Suite. pages 3--35. 2006. Google Scholar
Digital Library
- Don Batory, Jacob Neal Sarvela, and Axel Rauschmayer. Scaling step-wise refinement. In Proc. 25th International Conference on Software Engineering, ICSE '03, pages 187--197, Washington, DC, USA, 2003. IEEE Computer Society. Google Scholar
Digital Library
- Alexandre Bergel, Stéphane Ducasse, and Oscar Nierstrasz. Classbox/j: controlling the scope of change in java. In Proc. 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, OOPSLA '05, pages 177--189, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- Alexandre Bergel, Stephane Ducasse, and Roel Wuyts. Classboxes: A minimal module model supporting local rebinding. In Proc. JMLC 2003 (Joint modular languages conference), volume 2789 of LNCS, pages 122--131. Springer-Verlag, 2003.Google Scholar
Cross Ref
- Torbjörn Ekman and Görel Hedin. The JastAdd extensible Java compiler. SIGPLAN Not., 42(10): 1--18, 2007. Google Scholar
Digital Library
- Martin Fowler. Refactoring: improving the design of existing code. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1999. Google Scholar
Digital Library
- E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns -Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. Google Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steele, Gilad Bracha, and Alex Buckley. The Java Language Specification, Java SE 7 Edition. Oracle America, Inc., 2011. Google Scholar
Digital Library
- Shan Shan Huang and Yannis Smaragdakis. Expressive and safe static reflection with morphj. SIGPLAN Not., 43(6): 79--89, June 2008. Google Scholar
Digital Library
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight java: a minimal core calculus for java and gj. ACM Trans. Program. Lang. Syst., 23(3): 396--450, May 2001. Google Scholar
Digital Library
- Stein Krogdahl, Birger Møller-Pedersen, and Fredrik Sørensen. Exploring the use of package templates for flexible re-use of collections of related classes. Journal of Obj. Tech., 8(7): 59--85, 2009.Google Scholar
Cross Ref
- E. Murphy-Hill and A. P. Black. Refactoring tools: Fitness for purpose. Software, IEEE, 25(5): 38--44, sept.-oct. 2008. Google Scholar
Digital Library
- Emerson Murphy-Hill, Chris Parnin, and Andrew P. Black. How we refactor, and how we know it. In Proc. 31st Intl. Conf. Software Engineering, ICSE '09, pages 287--297, Washington, DC, USA, 2009. IEEE Computer Society. Google Scholar
Digital Library
- Nathaniel Nystrom, Michael R. Clarkson, and Andrew C. Myers. Polyglot: an extensible compiler framework for java. In Proc. 12th intl. conf. on Compiler construction, CC'03, pages 138--152, Berlin, Heidelberg, 2003. Springer-Verlag. Google Scholar
Digital Library
- W. Opdyke and R. E. Johnson. Refactoring, an aid in designing application frameworks and evolving object-oriented systems. In Proc. Symposium on Object Oriented Programming Emphasizing Practical Applications (SOOPA), 1990.Google Scholar
- William F. Opdyke. Refactoring Object-Oriented Frameworks. PhD thesis, University of Illinois, Urbana-Champaign, IL, USA, 1992. Google Scholar
Digital Library
- Christian Prehofer. Feature-oriented programming: A fresh look at objects. In Proc. European Conference on Object-Oriented Programming, pages 419--443, 1997.Google Scholar
- Max Schäfer, Torbjörn Ekman, and Oege de Moor. Sound and extensible renaming for java. In Proc. OOPSLA '08, OOPSLA '08, pages 277--294, New York, NY, USA, 2008. ACM. Google Scholar
Digital Library
- Håkon Stordahl. BooPT: Implementasjon av package templates for Boo. Master's thesis, Dept. of Informatics, Uni. Oslo, Gaustadalléen 23B, Postboks 1080 Blindern, 0316 Oslo, 2012.Google Scholar
- Alessandro Warth, Milan Stanojević, and Todd Millstein. Statically scoped object adaptation with expanders. In Proc. 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications, OOPSLA '06, pages 37--56, New York, NY, USA, 2006. ACM. Google Scholar
Digital Library
- Stefan Wehr, Ralf Lämmel, and Peter Thiemann. JavaGI: Generalized Interfaces for Java. In ECOOP 2007, Proceedings, LNCS. Springer-Verlag, July 2007. Google Scholar
Digital Library
- Stefan Wehr and Peter Thiemann. Javagi in the battlefield: practical experience with generalized interfaces. In Proc. eighth international conference on Generative programming and component engineering, GPCE '09, pages 65--74, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
Index Terms
Package templates: a definition by semantics-preserving source-to-source transformations to efficient Java code
Recommendations
Package templates: a definition by semantics-preserving source-to-source transformations to efficient Java code
GPCE '12: Proceedings of the 11th International Conference on Generative Programming and Component EngineeringPackage Templates (PT) is a mechanism designed for writing reusable modules, called templates, each consisting of a set of classes that can be adapted to their use in a program through compile-time specialization. A template must be instantiated in a ...
Reuse and combination with package templates
MASPEGHI '10: Proceedings of the 4th Workshop on MechAnisms for SPEcialization, Generalization and inHerItancePackage Templates (PT) is a mechanism for writing modules meant for reuse, where each module (template) consists of a collection of classes. Such a template must be instantiated in a program (at compile time) to form a set of ordinary classes, and ...
A comparison of generic template support: ada, C++, C#, and javaTM
Ada-Europe'10: Proceedings of the 15th Ada-Europe international conference on Reliable Software TechnologiesGenerics (also known as templates) have become a standard feature of modern programming languages, offering parameterization by data types and possibly other entities. Generics support efficient type-safe container data structures, general-purpose ...






Comments