Skip to Main content Skip to Navigation
Reports

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

Luigi Liquori 1, 2 Arnaud Spiwack 2
2 MIRHO - Objects, types and prototypes : semantics and validation
CRISAM - Inria Sophia Antipolis - Méditerranée , UHP - Université Henri Poincaré - Nancy 1, Université Nancy 2, INPL - Institut National Polytechnique de Lorraine, CNRS - Centre National de la Recherche Scientifique : UMR7503
Abstract : 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.
Complete list of metadatas

Cited literature [1 references]  Display  Hide  Download

https://hal.inria.fr/inria-00070751
Contributor : Rapport de Recherche Inria <>
Submitted on : Friday, May 19, 2006 - 9:30:33 PM
Last modification on : Saturday, January 27, 2018 - 1:31:23 AM
Long-term archiving on: : Sunday, April 4, 2010 - 9:50:44 PM

Identifiers

  • HAL Id : inria-00070751, version 1

Collections

Relations

Citation

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⟩

Share

Metrics

Record views

199

Files downloads

217