Abstract
We present FJig, a simple calculus where basic building blocks are classes in the style of Featherweight Java, declaring fields, methods and one constructor. However, inheritance has been generalized to the much more flexible notion originally proposed in Bracha’s Jigsaw framework. That is, classes play also the role of modules, that can be composed by a rich set of operators, all of which can be expressed by a minimal core.
We keep the nominal approach of Java-like languages, that is, types are class names. However, a class is not necessarily a structural subtype of any class used in its defining expression.
The calculus allows the encoding of a large variety of different mechanisms for software composition in class-based languages, including standard inheritance, mixin classes, traits and hiding. Hence, FJig can be used as a unifying framework for analyzing existing mechanisms and proposing new extensions.
We provide two different semantics of an FJig program: flattening and direct semantics. The difference is analogous to that between two intuitive models to understand inheritance: the former where inherited methods are copied into heir classes, and the latter where member lookup is performed by ascending the inheritance chain. Here we address equivalence of these two views for a more sophisticated composition mechanism.
This work has been partially supported by MIUR EOS DUE - Extensible Object Systems for Dynamic and Unpredictable Environments.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Ancona, D., Lagorio, G., Zucca, E.: Jam–designing a Java extension with mixins. ACM Transactions on Programming Languages and Systems 25(5), 641–712 (2003)
Ancona, D., Zucca, E.: Overriding operators in a mixin-based framework. In: Hartel, P.H., Kuchen, H. (eds.) PLILP 1997. LNCS, vol. 1292. Springer, Heidelberg (1997)
Ancona, D., Zucca, E.: A calculus of module systems. Journ. of Functional Programming 12(2), 91–132 (2002)
Bergel, A., Ducasse, S., Nierstrasz, O., Wuyts, R.: Stateful traits. In: De Meuter, W. (ed.) ISC 2006. LNCS, vol. 4406, pp. 66–90. Springer, Heidelberg (2007)
Bergel, A., Ducasse, S., Nierstrasz, O., Wuyts, R.: Stateful traits and their formalization. Comput. Lang. Syst. Struct. 34(2-3), 83–108 (2008)
Bono, V., Damiani, F., Giachino, E.: Separating type, behavior, and state to achieve very fine-grained reuse. In: 9th Intl. Workshop on Formal Techniques for Java-like Programs (2007)
Bono, V., Damiani, F., Giachino, E.: On traits and types in a Java-like setting. In: TCS 2008 - IFIP Int. Conf. on Theoretical Computer Science. Springer, Heidelberg (2008)
Bracha, G.: The Programming Language JIGSAW: Mixins, Modularity and Multiple Inheritance. PhD thesis, Department of Comp. Sci., Univ. of Utah (1992)
Duggan, D., Sourelis, C.: Mixin modules. In: Intl. Conf. on Functional Programming 1996. ACM Press, New York (1996)
Fisher, K., Reppy, J.: A typed calculus of traits. In: FOOL 2004 - Intl. Workshop on Foundations of Object Oriented Languages (2004)
Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: ACM Symp. on Principles of Programming Languages 1998. ACM Press, New York (1998)
Gamma, E., Helm, R., Johnson, R.E., Vlissides, J.M.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Professional Computing Series. Addison-Wesley, Reading (1995)
Hirschowitz, T., Leroy, X.: Mixin modules in a call-by-value setting. In: Le Métayer, D. (ed.) ESOP 2002. LNCS, vol. 2305, pp. 6–20. Springer, Heidelberg (2002)
Hirschowitz, T., Leroy, X., Wells, J.B.: Call-by-value mixin modules. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 64–78. Springer, Heidelberg (2004)
Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–450 (2001)
Lagorio, G., Servetto, M., Zucca, E.: Featherweight Jigsaw - a minimal core calculus for modular composition of classes. Technical report, Dipartimento di Informatica e Scienze dell’Informazione, Università di Genova (December 2008) (Full version)
Lagorio, G., Servetto, M., Zucca, E.: Flattening versus direct semantics for Featherweight Jigsaw. In: FOOL 2009 - Intl. Workshop on Foundations of Object Oriented Languages (2009)
Leavens, G.T.: Tutorial on JML, the Java modeling language. In: Automated Software Engineering (ASE 2007). ACM Press, New York (2007)
Liquori, L., Spiwack, A.: FeatherTrait: A modest extension of Featherweight Java. ACM Transactions on Programming Languages and Systems 30(2) (2008)
Schärli, N., Ducasse, S., Nierstrasz, O., Black, A.P.: Traits: Composable units of behaviour. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743. Springer, Heidelberg (2003)
Wells, J.B., Vestergaard, R.: Confluent equational reasoning for linking with first-class primitive modules. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 412. Springer, Heidelberg (2000)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Lagorio, G., Servetto, M., Zucca, E. (2009). Featherweight Jigsaw: A Minimal Core Calculus for Modular Composition of Classes . In: Drossopoulou, S. (eds) ECOOP 2009 – Object-Oriented Programming. ECOOP 2009. Lecture Notes in Computer Science, vol 5653. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03013-0_12
Download citation
DOI: https://doi.org/10.1007/978-3-642-03013-0_12
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-03012-3
Online ISBN: 978-3-642-03013-0
eBook Packages: Computer ScienceComputer Science (R0)