Abstract
We present MJ: a language for specifying general classes whose members are produced by iterating over members of other classes. We call this technique “class morphing” or just “morphing”. Morphing extends the notion of genericity so that not only types of methods and fields, but also the structure of a class can vary according to type variables. This offers the ability to express common programming patterns in a highly generic way that is otherwise not supported by conventional techniques. For instance, morphing lets us write generic proxies (i.e., classes that can be parameterized with another class and export the same public methods as that class); default implementations (e.g., a generic do-nothing type, configurable for any interface); semantic extensions (e.g., specialized behavior for methods that declare a certain annotation); and more. MJ’s hallmark feature is that, despite its emphasis on generality, it allows modular type checking: an MJ class can be checked independently of its uses. Thus, the possibility of supplying a type parameter that will lead to invalid code is detected early—an invaluable feature for highly general components that will be statically instantiated by other programmers.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Allen, E., Bannet, J., Cartwright, R.: A first-class approach to genericity. In: Proc. of the 18th annual ACM SIGPLAN conference on Object-oriented Programming, Systems, Languages, and Applications, Anaheim, CA, pp. 96–114. ACM Press, New York (2003)
Bachrach, J., Playford, K.: The Java syntactic extender (JSE). In: Proc. of the 16th ACM SIGPLAN conference on Object Oriented Programming, Systems, Languages, and Applications, Tampa Bay, FL, pp. 31–42. ACM Press, New York (2001)
Baker, J., Hsieh, W.C.: Maya: multiple-dispatch syntax extension in Java. In: Proc. of the ACM SIGPLAN Conference on Programming Language Design and Implementation, Berlin, Germany, pp. 270–281. ACM Press, New York (2002)
Batory, D., Lofaso, B., Smaragdakis, Y.: JTS: tools for implementing domain-specific languages. In: Proc. of the Fifth Intl. Conf. on Software Reuse, Victoria, BC, Canada, pp. 143–153. IEEE Computer Society Press, Los Alamitos (1998)
Bracha, G., Cook, W.: Mixin-based inheritance. In: OOPSLA/ECOOP ’90. Proc. of the European conference on object-oriented programming on Object Oriented Programming Systems, Languages, and Applications, Ottawa, Canada, pp. 303–311. ACM Press, New York (1990)
Burke, B., et al.: JBoss AOP Web site (accessed April 2007), http://www.jboss.org/products/aop
Calcagno, C., Taha, W., Huang, L., Leroy, X.: Implementing multi-stage languages using ASTs, gensym, and reflection. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 57–76. Springer, Heidelberg (2003)
Csallner, C., Smaragdakis, Y.: JCrasher: An automatic robustness tester for Java. Software—Practice and Experience 34(11), 1025–1050 (2004)
Danforth, S., Forman, I.R.: Reflections on metaclass programming in SOM. In: Proc. of the 9th ACM SIGPLAN conference on Object Oriented Programming, Systems, Languages, and Applications, pp. 440–452. ACM Press, New York (1994)
Draheim, D., Lutteroth, C., Weber, G.: A type system for reflective program generators. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 327–341. Springer, Heidelberg (2005)
Fähndrich, M., Carbin, M., Larus, J.R.: Reflective program generation with patterns. In: Proc. of the 5th Intl. conference on Generative Programming and Component Engineering, Portland, OR, pp. 275–284. ACM Press, New York (2006)
Gamma, E., Helm, R., Johnson, R.: Design Patterns. Elements of Reusable Object-Oriented Software. Addison-Wesley Professional Computing Series. Addison-Wesley, Reading (1995)
Huang, S.S., Zook, D., Smaragdakis, Y.: Statically safe program generation with SafeGen. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 309–326. Springer, Heidelberg (2005)
Huang, S.S., Zook, D., Smaragdakis, Y.: Morphing: Safely shaping a class in the image of others. Technical report (2006), http://www.cc.gatech.edu/~ssh/mjfull.pdf
Huang, S.S., Zook, D., Smaragdakis, Y.: cJ: Enhancing Java with safe type conditions. In: Proc. of the 6th Intl. Conf. on Aspect-Oriented Software Development, Vancouver, Canada, ACM Press, New York (2007)
Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. In: Meissner, L. (ed.) Proc. of the 14th ACM SIGPLAN conference on Object-oriented Programming, Systems, Languages, and Applications, vol. 34(10), pp. 132–146 (1999)
Igarashi, A., Viroli, M.: Variant parametric types: A flexible subtyping scheme for generics. ACM Trans. Program. Lang. Syst. 28(5), 795–847 (2006)
Kiczales, G., des Rivieres, J., Bobrow, D.G.: The Art of the Metaobject Protocol. MIT Press, Cambridge (1991)
Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of AspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–353. Springer, Heidelberg (2001)
Kiczales, G., Lamping, J., Menhdhekar, A., Maeda, C., Lopes, C., Loingtier, J.-M., Irwin, J.: Aspect-oriented programming. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)
Sheard, T., Jones, S.P.: Template meta-programming for Haskell. In: Proc. of the ACM SIGPLAN workshop on Haskell, Pittsburgh, Pennsylvania, pp. 1–16. ACM Press, New York (2002)
Smaragdakis, Y., Batory, D.: Implementing layered designs with mixin layers. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 550–570. Springer, Heidelberg (1998)
Taha, W., Sheard, T.: Multi-stage programming with explicit annotations. In: Proc. of the 1997 ACM SIGPLAN symposium on Partial Evaluation and semantics-based Program Manipulation, Amsterdam, The Netherlands, pp. 203–217. ACM Press, New York (1997)
Torgersen, M., Hansen, C.P., Ernst, E., von der Ahe, P., Bracha, G., Gafter, N.: Adding wildcards to the java programming language. In: Proc. of the 2004 ACM Symposium on Applied Computing, Nicosia, Cyprus, 2004, pp. 1289–1296. ACM Press, New York (2004)
Visser, E.: Program transformation with Stratego/XT: Rules, strategies, tools, and systems in Stratego/XT 0.9. In: Lengauer, C., Batory, D., Consel, C., Odersky, M. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 216–238. Springer, Heidelberg (2004)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Huang, S.S., Zook, D., Smaragdakis, Y. (2007). Morphing: Safely Shaping a Class in the Image of Others. In: Ernst, E. (eds) ECOOP 2007 – Object-Oriented Programming. ECOOP 2007. Lecture Notes in Computer Science, vol 4609. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-73589-2_19
Download citation
DOI: https://doi.org/10.1007/978-3-540-73589-2_19
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-73588-5
Online ISBN: 978-3-540-73589-2
eBook Packages: Computer ScienceComputer Science (R0)