DIPARTIMENTO   DI   INFORMATICA
Università di Torino

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).


This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to http://unlicense.org/


[Ferruccio Damiani's HOME]

Last update: Mar 18, 2025