The Byte Code Composer Tools
We want to be able to distribute binary versions of layers (features). Currently, we distribute and compose source code only. The byte code composer tools are a preliminary and experimental first step toward our ultimate goal of distributing binary layers (features). The idea is to translate each jak file into a stylized Java file -- meaning that there are coding and naming conventions in the Java file that will allow us to express (and hence recognize) refines constructs. One tool, bcjak2java does this translation. Its command line input is a single Jak file and it produces the stylized Java file as output.
The basic idea in stylizing is to emulate mixin layers. For stylized Java code to be compiled, we need to create a stub for every class and interface that is the union of all possible methods and members that can appear within it. The tool bcstubgenerator performs this task. To translate all Jak files in a directory into Java files, the bcj2j script is used. After creating the stub layer, the stylized java classes can be compiled. A script bccomposer composes bytecode layers.
The bcmixin tool is a byte code composition tool for java class files. Its composition rules are similar with the mixin tool in AHEAD. The stylized Java code for the bcmixin tool are:
How to run it:
In the ahead/build/bin directory (and also in the standalone/bcbinScripts) directory, you will find the following Bash script files:
1. Translate the jak files into java files:
If your model is based on jak files, to run the bcmixin tools, you should translate jak files to java file first. The script file bcj2j performs this translation:
>bcj2j <model name>
Here, you should run the bcj2j in the directory which includes your model. After your model is translated into pure java files, then you can use bcmixin tools to compile and compose your model.
2. Run bcmixin tools
You can run bcmixin tools in two modes: by hand or by a script file.
1. By hand:
To compile your model:
1. run bcstubgenerator.Main [modelname] to get stub&refine directory
2. compile stub&refine using the standard java compiler
3. run bctostub.Main [stub directory] on stub directory
4. run jrename to rename all the classes in current model
5. on linux, compile each layer with: javac –classpath .:refine:stub <layer_name>/*\$\$.java
on windows, compile each layer with javac -classpath .\;refine\;stub <layer_name>/*\$\$.java
To compose an executable application from your model:
1. run java bcmixin.Main [modelname] [equation file]
2. make an executable jar file
2. By a script file:
1. run bcj2j <model>
2. run the script file bccompiler [modelname] to compile your model.
3. run the script file bccomposer [modelname] [equation file] to get an executable jar file from your model by the given equation file.
cd GPL directory
run in bash:
> rm -r gpl\$\$ > bcj2j gpl > bccompiler gpl > bccomposer gpl\$\$ dgraph
The bytecode tools should be part of the standard ATS distribution. In case they are not, here is how to build the tools:
using the build file bctools.xml to build the tools:
>ant –f bctools.xml bcmixin -build the bcmxin tool
>ant –f bctools.xml bcstubgenerator -build the bcstubgenerator tool
>ant –f bctools.xml bctostub -build the bctostub tool
>ant –f bctools.xml -build all
After build it, put the jar files in the build/lib directory and bcel.jar in the lib directory in your classpath. Also put the AHEAD tools: mmatrix.jar, bcjak2java.jar, mmatrix.jar in your classpath. You also need to put the bin directory in your path so you can run the script files.