Elena: A StateJ to Java translator
Elena is a prototype implementation of a code generator that converts
an extension of Java including state
classes ([Damiani, Giachino, Giannini and Drossopoulou, 2008] [Damiani, Giachino, Giannini and Cazzola, 2008]
into Java. The syntax of the
input language is Java 1.4 plus state
classes and the state change expression. The syntax is given by the
following diagrams.
Downloading
The current version of Elena (1.0), released (as Unlicensed Free Software -- http://unlicense.org/) in December 2010, can be obtained from here.
Example of stateJ classes from the paper from here. A solution of the Santa Claus problem using state classes can be found here.
Requirements
You will
need Java 1.5 or above to run the translator (and the .java code generated).
Usage
Once downloaded you can invoke elena as follows:
extract elena.zip. You will get a directory elena containing 2 subdirectories: 1) lib (containing the .jar file to run) and 2) work (where to put the .statej files that have to be translated).
put the .statej
classes to translate in the directory elena/work.
run (from the directory containing the subdirectory
elena)
java -jar elena/lib/elena.jar (for windows users you can just run elena.bat)
This will produce a .java file
for each of the .statej files
present in the elena/work directory.
Now you can compile the .java classes using javac and use any .java standard test class to
run them. The files produced are in the elena.work package and therefore they must be compiled
(and run) from the root directory (the
one containing elena/work).
In the samples that you download, you will find Test
classes for each file.
Instrumenting the generated code
As you can see the files .java produced from the
translation have a variable declared:
final static boolean VERBOSE = true;
that can be used to instrument the code to write more or less
verbose messages regarding the state transitions.
A Note on Translatating .statej Subclasses
As you can see one of the examples is the class ReaderWriterFair.statej
that extends ReaderWriter.statej. In order to translate ReaderWriterFair.statej
in the directory elena/work must be present ReaderWriter.class (this is because the translation process
uses reflection to check for presence of methods in the superclass). So if
you run elena with both ReaderWriter.statej and ReaderWriterFair.statej
in the directory, the first one will be translated
correctly, whereas the second will be translated, but could be incorrect.
More details on the translation process
Can be found in
the Master Thesis of Emanuele Cazzola (in Italian).
|