MetaFJig: a meta-circular composition language for Java-like classes

We propose a Java-like language where class definitions are first class values and new classes can be derived from existing ones by exploiting the full power of the language itself, used on top of a small set of primitive composition operators, instead of using a fixed mechanism like inheritance. Hence, compilation requires to perform (meta-)reduction steps, by a process that we call compile-time execution. This approach differs from meta-programming techniques available in mainstream languages since it is meta-circular, hence programmers are not required to learn new syntax and idioms. Compile-time execution is guaranteed to be sound (not to get stuck) by a lightweight technique, where class composition errors are detected dynamically, and conventional typing errors are detected by interleaving typechecking with meta-reduction steps. This allows for a modular approach, that is, compile-time execution is defined, and can be implemented, on top of typechecking and execution of the underlying language. Moreover, programmers can handle errors due to composition operators. Besides soundness, our technique ensures an additional important property called meta-level soundness, that is, typing errors never originate from (meta-)code in already compiled programs.

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

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

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

[4]  Mirko Viroli,et al.  Lightweight Family Polymorphism , 2005, APLAS.

[5]  Michael D. Ernst,et al.  Javari: adding reference immutability to Java , 2005, OOPSLA '05.

[6]  Leon Sterling,et al.  The Art of Prolog - Advanced Programming Techniques , 1986 .

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

[8]  Xin Qi,et al.  J&: nested intersection for scalable software composition , 2006, OOPSLA '06.

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

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

[11]  Erik Ernst,et al.  Higher-Order Hierarchies , 2003, ECOOP.

[12]  John Tang Boyland,et al.  Parasitic methods: an implementation of multi-methods for Java , 1997, OOPSLA '97.

[13]  Marco Servetto Strong exception-safety for Java-like languages , 2009, ICTCS.

[14]  Shan Shan Huang,et al.  Generating AspectJ Programs with Meta-AspectJ , 2004, GPCE.

[15]  Kim B. Bruce,et al.  LOOJ: Weaving LOOM into Java , 2004, ECOOP.

[16]  Robert Glück,et al.  Generative Programming and Active Libraries , 1998, Generic Programming.

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

[18]  Vitaly Shmatikov,et al.  A Core Calculus of Classes and Mixins , 1999, ECOOP.

[19]  Simon L. Peyton Jones,et al.  Dynamic typing as staged type inference , 1998, POPL '98.

[20]  Gary T. Leavens,et al.  MultiJava: Design rationale, compiler implementation, and applications , 2006, TOPL.

[21]  Davide Ancona,et al.  True Modules for Java-like Languages , 2001, ECOOP.

[22]  Joe B. Wells,et al.  Type inference, principal typings, and let-polymorphism for first-class mixin modules , 2005, ICFP '05.

[23]  Leon Sterling,et al.  The art of Prolog (2nd ed.): advanced programming techniques , 1994 .

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

[25]  Walter Bright,et al.  The D Programming Language , 2010 .

[26]  Matthew Flatt,et al.  Jiazzi: new-age components for old-fasioned Java , 2001, OOPSLA '01.

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

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

[29]  Tim Sheard,et al.  Accomplishments and Research Challenges in Meta-programming , 2001, SAIG.

[30]  Shan Shan Huang,et al.  Statically safe program generation with safegen , 2005, GPCE'05.

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

[32]  Frank Piessens,et al.  Failboxes: Provably Safe Exception Handling , 2009, ECOOP.

[33]  Davide Ancona,et al.  Compositional Compilation for Java-like Languages through Polymorphic Bytecode , 2005 .

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

[35]  Ina Schaefer,et al.  Implementing software product lines using traits , 2010, SAC '10.

[36]  Jens Palsberg,et al.  Constrained types for object-oriented languages , 2008, OOPSLA.

[37]  Davide Ancona,et al.  A theory of mixin modules: basic and derived operators , 1998, Mathematical Structures in Computer Science.

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

[39]  Davide Ancona,et al.  Flexible Type-Safe Linking of Components for Java-Like Languages , 2006, JMLC.

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

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

[42]  Erik Poll,et al.  Type-based Object Immutability with Flexible Initialization - extended version , 2009 .

[43]  Aaron Turon,et al.  Metaprogramming with Traits , 2007, ECOOP.

[44]  Oscar Nierstrasz,et al.  Traits: A mechanism for fine-grained reuse , 2006, TOPL.

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

[46]  Martin Odersky,et al.  Capabilities for Uniqueness and Borrowing , 2010, ECOOP.

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

[48]  Shigeru Chiba,et al.  OpenJava: A Class-Based Macro System for Java , 1999, Reflection and Software Engineering.

[49]  Elena Zucca,et al.  Featherweight Jigsaw - Replacing inheritance by composition in Java-like languages , 2012, Inf. Comput..

[50]  Leon Sterling,et al.  The Art of Prolog , 1987, IEEE Expert.

[51]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[52]  William R. Cook,et al.  Mixin-based inheritance , 1990, OOPSLA/ECOOP '90.

[53]  Michael D. Ernst,et al.  Ownership and immutability in generic Java , 2010, OOPSLA.

[54]  Lorenzo Bettini,et al.  A Calculus for Boxes and Traits in a Java-Like Setting , 2010, COORDINATION.

[55]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..

[56]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[57]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[58]  Sophia Drossopoulou,et al.  Tribe: a simple virtual class calculus , 2007, AOSD.

[59]  Gregor Kiczales,et al.  Aspect-oriented programming , 2001, ESEC/FSE-9.

[60]  Krzysztof Czarnecki,et al.  Generative programming - methods, tools and applications , 2000 .

[61]  Gilad Bracha,et al.  Modularity meets inheritance , 1992, Proceedings of the 1992 International Conference on Computer Languages.

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

[63]  Sophia Drossopoulou,et al.  Chai: Traits for Java-Like Languages , 2005, ECOOP.

[64]  Robert Bruce Findler,et al.  Modular object-oriented programming with units and mixins , 1998, ICFP '98.

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

[66]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[67]  Krzysztof Czarnecki,et al.  DSL Implementation in MetaOCaml, Template Haskell, and C++ , 2003, Domain-Specific Program Generation.

[68]  Robert Glück,et al.  Generative Programming and Active Libraries , 1998, Generic Programming.

[69]  Erik Ernst,et al.  Family Polymorphism , 2001, ECOOP.

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

[71]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

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

[73]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

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

[75]  Shan Shan Huang,et al.  Morphing: Safely Shaping a Class in the Image of Others , 2007, ECOOP.

[76]  Mads Torgersen The Expression Problem Revisited , 2004, ECOOP.

[77]  Paul King,et al.  Groovy in Action , 2007 .

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

[79]  David Lorge Parnas,et al.  Review of David L. Parnas' "Designing Software for Ease of Extension and Contraction" , 2004 .

[80]  Walid Taha,et al.  Mint: Java multi-stage programming using weak separability , 2010, PLDI '10.

[81]  Yaron Kashai,et al.  Modules as Objects in Newspeak , 2010, ECOOP.

[82]  David Notkin,et al.  Architectural Reasoning in ArchJava , 2002, ECOOP.

[83]  Martin Odersky,et al.  A Statically Safe Alternative to Virtual Types , 1998, ECOOP.

[84]  Gary Lindstrom,et al.  An Application Framework For Module Composition Tools , 1996, ECOOP.

[85]  William R. Cook,et al.  A virtual class calculus , 2006, POPL '06.

[86]  Luigi Liquori,et al.  Extending FeatherTrait Java with Interfaces , 2008, Theor. Comput. Sci..

[87]  Joseph Gil,et al.  Are We Ready for a Safer Construction Environment? , 2009, ECOOP.

[88]  David A. Moon,et al.  Object-oriented programming with flavors , 1986, OOPLSA '86.

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