Flattening versus direct semantics for Featherweight
Jigsaw
Giovanni Lagorio, Marco Servetto and Elena Zucca
Abstract
Inheritance
in object-oriented languages allows, roughly, to obtain the same effect
one would get by duplicating the methods of the parent class in the
heir. However, the key advantage is that source code duplication is
avoided, and parent's code is, instead, found on demand, through a
runtime procedure called method look-up. In other words, two different
semantics of inheritance can be given: flattening semantics, that is,
by translation into a language with no inheritance, and direct
semantics, that is, by formalizing dynamic method look-up. Analogously,
many other composition mechanisms which have been proposed for
enhancing the object-oriented paradigm, such as mixins and traits, can
be formally defined either by translation into standard inheritance, or
by a providing a direct execution model. The former, simpler,
alternative has been generally taken in the literature. However,
flattening semantics is not adequate for compositional analysis since
the binary code for each code fragment, say, a class, can be generated
only when all (directly or indirectly) used fragments are available.
For this reason, in this paper we propose a direct semantic for
Featherweight Jigsaw, a class-based language providing a very general
framework for software composition, subsuming, besides other
mechanisms, standard inheritance, mixins, and traits. Then, we prove
equivalence with flattening semantics.
Presented at FOOL'09; Saturday, 24 January
2009, Savannah, Georgia, USA.