Spoon: Program Analysis and Transformation in Java - Inria - Institut national de recherche en sciences et technologies du numérique Access content directly
Reports (Research Report) Year : 2006

Spoon: Program Analysis and Transformation in Java


In this research report, we present Spoon, a framework for program transformation and static analysis in Java. More precisely, Spoon is an open and extensible Java compiler, written in pure Java by using Compile-time reflection techniques. We take advantage of the new features added by Java 5, and particularly of annotations and generics. Using annotations within the Spoon framework allows the programmer to extend the Java language without defining new syntactic elements, and in such a way that it is naturally supported by IDEs for Java 5 and greater. Generics, as a priceless complement, allow for the well-typing of Spoon programs that implement the programmers' language extensions. Enforcing typing naturally provides better IDE support (such as static checks, completion, documentation, and navigation), and also allows us to define a pure Java template mechanism, which we use as a tool to define well-typed and straightforward program transformations. In addition to its basic transformation capabilities, Spoon comes with a partial evaluation engine that is used to calculate the control flow of the program and to simplify the results of template-based transformations for correctness, optimization, and readability. In order to demonstrate the usability and usefulness of our framework, we present three applications, which have been chosen to cover most of Spoon's features: a translator from Java 1.4 programs into well-typed Java 5 programs, an efficient template-based AOP extension, and an automatic implementation and validation of the visitor pattern.
Fichier principal
Vignette du fichier
RR-5901.pdf (252.24 Ko) Télécharger le fichier

Dates and versions

inria-00071366 , version 1 (23-05-2006)


  • HAL Id : inria-00071366 , version 1


Renaud Pawlak, Carlos Noguera, Nicolas Petitprez. Spoon: Program Analysis and Transformation in Java. [Research Report] RR-5901, Inria. 2006. ⟨inria-00071366⟩
1068 View
1264 Download


Gmail Facebook Twitter LinkedIn More