Featherweight Jigsaw - Replacing inheritance by composition in Java-like languages

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 [email protected]?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. Fields and methods can be declared of four different kinds (abstract, virtual, frozen, local) determining how they are affected by the operators. 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. While this allows a more flexible reuse, it may prevent the (generalized) inheritance relation from being a subtyping relation. So, the required subtyping relations among classes are declared by the programmer and checked by the type system. 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.

[1]  Elena Zucca,et al.  Customizable composition operators for Java-like classes ( extended abstract ) , 2009 .

[2]  Viviana Bono,et al.  On Traits and Types in a Java-like Setting , 2008, IFIP TCS.

[3]  Tom Hirschowitz,et al.  Mixin modules in a call-by-value setting , 2002, TOPL.

[4]  Davide Ancona,et al.  A calculus of module systems , 2002, J. Funct. Program..

[5]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[6]  Tom Hirschowitz,et al.  Call-by-Value Mixin Modules: Reduction Semantics, Side Effects, Types , 2004, ESOP.

[7]  Oscar Nierstrasz,et al.  Flattening Traits , 2006, J. Object Technol..

[8]  Joe B. Wells,et al.  Equational Reasoning for Linking with First-Class Primitive Modules , 2000, ESOP.

[9]  Xin Qi,et al.  Nested Intersection for Scalable Software Composition (Technical Report) , 2006 .

[10]  Luigi Liquori,et al.  FeatherTrait: A modest extension of Featherweight Java , 2008, TOPL.

[11]  Andrew C. Myers,et al.  Scalable extensibility via nested inheritance , 2004, OOPSLA.

[12]  Elena Zucca,et al.  Customizable composition operators for Java-like classes , 2009, ICTCS.

[13]  Davide Ancona,et al.  Jam - A Smooth Extension of Java with Mixins , 2000, ECOOP.

[14]  Elena Zucca,et al.  MetaFJig: a meta-circular composition language for Java-like classes , 2010, OOPSLA.

[15]  Mirko Viroli,et al.  Lightweight family polymorphism , 2008, J. Funct. Program..

[16]  Dominic Duggan,et al.  Mixin modules , 1996, ICFP '96.

[17]  Elena Zucca,et al.  A Lightweight Approach to Customizable Composition Operators for Java-like Classes , 2010, Electron. Notes Theor. Comput. Sci..

[18]  Oscar Nierstrasz,et al.  Stateful traits and their formalization , 2008, Comput. Lang. Syst. Struct..

[19]  W. Cook,et al.  A Virtual Class Calculus , 2005 .

[20]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

[21]  Gary T. Leavens Tutorial on JML, the java modeling language , 2007, ASE '07.

[22]  Davide Ancona,et al.  Overriding Operators in a Mixin-Based Framework , 1997, PLILP.

[23]  Mirko Viroli,et al.  Variant path types for scalable extensibility , 2007, OOPSLA.

[24]  E. Zucca,et al.  Flattening versus direct semantics for Featherweight Jigsaw ∗ , 2007 .

[25]  Gilad Bracha,et al.  The programming language jigsaw: mixins, modularity and multiple inheritance , 1992 .

[26]  Martin Odersky,et al.  Independently Extensible Solutions to the Expression Problem , 2004 .

[27]  Elena Zucca,et al.  Featherweight Jigsaw: A Minimal Core Calculus for Modular Composition of Classes , 2009, ECOOP.

[28]  Elena Zucca,et al.  DeepFJig - Modular composition of nested classes , 2012, J. Object Technol..

[29]  Oscar Nierstrasz,et al.  Traits: Composable Units of Behaviour , 2002, ECOOP.

[30]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 1999, OOPSLA '99.

[31]  DeLesley Hutchins,et al.  Eliminating distinctions of class: using prototypes to model virtual classes , 2006, OOPSLA '06.

[32]  Viviana Bono,et al.  Separating Type, Behavior, and State to Achieve Very Fine-grained Reuse , 2007 .

[33]  Davide Ancona,et al.  Jam---designing a Java extension with mixins , 2003, TOPL.

[34]  Oscar Nierstrasz,et al.  Stateful Traits , 2006, ISC.