Skip to Main content Skip to Navigation
Journal articles

FeatherTrait: A Modest Extension of Featherweight Java

Luigi Liquori 1 Arnaud Spiwack 2, 3
2 TYPICAL - Types, Logic and computing
LIX - Laboratoire d'informatique de l'École polytechnique [Palaiseau], Inria Saclay - Ile de France
Abstract : In the context of statically-typed, class-based languages, we investigate classes that can be extended with trait composition. A trait is a collection of methods without state; it can be viewed as an incomplete stateless class. Traits can be composed in any order, but only make sense when imported by a class that provides state variables and additional methods to disambiguate conflicting names arising between the imported traits. We introduce FeatherTrait Java (FTJ), a conservative extension of the simple lightweight class-based calculus Featherweight Java (FJ) with statically-typed traits. In FTJ, classes can be built using traits as basic behavioral bricks; method conflicts between imported traits must be resolved explicitly by the user either by (i) aliasing or excluding method names in traits, or by (ii) overriding explicitly the conflicting methods in the class or in the trait itself. We present an operational semantics with a lookup algorithm, and a sound type system that guarantees that evaluating a well-typed expression never yields a message-not-understood run-time error nor gets the interpreter stuck. We give examples of the increased expressive power of the trait-based inheritance model. The resulting calculus appears to be a good starting point for a rigorous mathematical analysis of typed class-based languages featuring trait-based inheritance.
Complete list of metadatas

Cited literature [46 references]  Display  Hide  Download

https://hal.inria.fr/inria-00432538
Contributor : Arnaud Spiwack <>
Submitted on : Monday, November 16, 2009 - 3:52:47 PM
Last modification on : Thursday, March 5, 2020 - 6:21:58 PM
Long-term archiving on: : Thursday, June 17, 2010 - 8:30:59 PM

File

fjtraits.pdf
Files produced by the author(s)

Identifiers

Collections

Citation

Luigi Liquori, Arnaud Spiwack. FeatherTrait: A Modest Extension of Featherweight Java. ACM Transactions on Programming Languages and Systems (TOPLAS), ACM, 2008, ACM Transactions on Programming Languages and Systems (TOPLAS), 30 (2), pp.11:1--11:32. ⟨10.1145/1330017.1330022⟩. ⟨inria-00432538⟩

Share

Metrics

Record views

570

Files downloads

569