JastAddJ: The JastAdd Extensible Java Compiler

JastAddJ is an extensible compiler for Java, implemented using JastAdd. The compiler consists of basic modules for Java 1.4, and extension modules for Java 1.5 and Java 7. (The language extensions introduced by Java 6 were very minor, and are included in the Java 1.5 modules.)

The following OOPSLA 2007 paper describes the architecture of the JastAddJ compiler, and the Java 1.4 and Java 1.5 modules:

The Java 7 modules were implemented as a M.Sc. project, and are described in the following report:

Although JastAddJ is built as a research project, it is a high quality compiler that can compile large Java programs. It is about 3 times slower than javac, which we think is very good for a generated compiler. You can use JastAddJ to build your own languages on top of Java, or to build program analyses for Java. See JastAddJ-Extensions for examples.


JastAddJ contains these top-level directories:

Each javaN directory contains extensions to the Java support based on the java(N-1) modules. Each such directory also contains the subdirectories grammar, frontend, parser, scanner. As may be expected the grammar directory contains the abstract grammar specifications, frontend contains frontend modules aspect files, backend contains the backend aspect files, parser and scanner include the parser and scanner specifications respectively.


You can get the latest JastAddJ version from JastAddJ's bitbucket. JastAddJ can either be downloaded from bitbucket as a compressed archive or using Git.

Our SVN repository for JastAddJ is still available, though it is no longer updated and we encourage you to switch to our bitbucket repository:

> svn checkout http://svn.cs.lth.se/svn/jastadd-oxford/projects/branches/JastAddJ-stable/


All tools needed (jastadd2, jflex, beaver, etc.) are included. You only need to have javac and Apache Ant installed in order to build.

Build the component you are interested in by running ant in its directory. Some components use the specifications in other components, so make sure they are all in sibling directories (as they will be if you check out the complete JastAddJ).

   > cd Java7Backend
   > ant

Note when running on Windows/Cygwin: Make sure that ant is in your PATH environment variable. Why? To build the Java 1.5 components, JastAdd needs to be run with more than the default heap size. This is handled by letting ant call itself using an exec task with a larger heap (see the build.xml files).


How to run the programs JavaChecker, JavaPrettyPrinter in the frontends:

   > java -cp jastaddj.jar org.jastadd.jastaddj.JavaChecker java-source-files
   > java -cp jastaddj.jar org.jastadd.jastaddj.JavaPrettyPrinter java-source-files

How to run the program JavaCompiler:

   > java -jar jastaddj.jar options java-source-files

See what options are available:

   > java -jar jastaddj.jar -help