We present a language extension, which integrates in a Java like language a mechanism for dynamically extending object behaviors without changing their type. Our approach consists in moving the addition of new features from class (static) level to object (dynamic) level: the basic features of entities (representing their structure) are separated from the additional ones (wrapper classes whose instances represent run-time added behaviors). At run-time, these entities can be dynamically composed by instantiating wrapper objects which are attached to basic entities. Wrappers permit specializing (wrapping) methods at run-time: the method of the wrapper will be automatically executed after the method of the wrapped objects, using a delegation mechanism. Furthermore, wrapped methods can return values and values returned by the wrapped methods are transparently made available in the wrapper methods. We formalize our extension by adding the new constructs to Featherweight Java and we prove that the core language so extended (Featherweight Wrap Java) is type safe.

Featherweight Wrap Java: Wrapping objects and methods / Bettini, Lorenzo; Capecchi, Sara; Giachino, Elena. - In: JOURNAL OF OBJECT TECHNOLOGY. - ISSN 1660-1769. - ELETTRONICO. - 7:(2008), pp. 5-29. [10.5381/jot.2008.7.2.a1]

Featherweight Wrap Java: Wrapping objects and methods

BETTINI, LORENZO;
2008

Abstract

We present a language extension, which integrates in a Java like language a mechanism for dynamically extending object behaviors without changing their type. Our approach consists in moving the addition of new features from class (static) level to object (dynamic) level: the basic features of entities (representing their structure) are separated from the additional ones (wrapper classes whose instances represent run-time added behaviors). At run-time, these entities can be dynamically composed by instantiating wrapper objects which are attached to basic entities. Wrappers permit specializing (wrapping) methods at run-time: the method of the wrapper will be automatically executed after the method of the wrapped objects, using a delegation mechanism. Furthermore, wrapped methods can return values and values returned by the wrapped methods are transparently made available in the wrapper methods. We formalize our extension by adding the new constructs to Featherweight Java and we prove that the core language so extended (Featherweight Wrap Java) is type safe.
2008
7
5
29
Bettini, Lorenzo; Capecchi, Sara; Giachino, Elena
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in FLORE sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificatore per citare o creare un link a questa risorsa: https://hdl.handle.net/2158/1074598
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 6
  • ???jsp.display-item.citation.isi??? ND
social impact