Featherweight-Trait Java : A Trait-based Extension for FJ - Inria - Institut national de recherche en sciences et technologies du numérique Access content directly
Reports (Research Report) Year : 2004

Featherweight-Trait Java : A Trait-based Extension for FJ


In the context of statically typed class-based languages, we investigate classes which might extend upon trait composition. Building classes by composing method-clusters is a well-known technique in implementing object- and class-based languages with simple inheritance, that has been explored in an untyped setting as a first-class mechanism available to the user only recently. This paper presents Featherweight-Trait Java (FTJ), a conservative extension of Featherweight Java (FJ), a simple light-weight class-based calculus take off with statically typed traits. In FTJ, classes can be built using traits as a basic behavioral brick; every trait contains only behavior and no state. Method conflicts between traits must be resolved explicitly by the user either (1) by aliasing or excluding method names, or (2) overriding explicitly in the class. A special emphasis has been put on dealing with "diamond'' conflict, a classical issue playing with multiple inheritance. That makes a kind of multiple inheritance not only possible but simple. As such, FTJ is as a proper extension of FJ. We present a new operational semantics with a new dynamic lookup algorithm, and a new sound type system that guarantees that evaluating a well-typed expression never yields a "message not understood'' run-time error nor get the interpreter stuck. We give an example which illustrates the increased expressive power of the typed trait-based (multiple inheritance) model of FTJ with respect to the classical (single inheritance) typed class-based one of FJ. The resulting calculus appears to be a good starting point for a rigorous mathematical analysis of typed trait-based languages, and a novel paradigm for typed trait-oriented programming.
Fichier principal
Vignette du fichier
RR-5247.pdf (327.34 Ko) Télécharger le fichier

Dates and versions

inria-00070751 , version 1 (19-05-2006)


  • HAL Id : inria-00070751 , version 1


Luigi Liquori, Arnaud Spiwack. Featherweight-Trait Java : A Trait-based Extension for FJ. [Research Report] RR-5247, INRIA Sophia Antipolis - Méditerranée; INRIA. 2004, pp.27. ⟨inria-00070751⟩
118 View
120 Download


Gmail Facebook Twitter LinkedIn More