The Generic Java Compiler

Martin Odersky

Purpose

The Generic Java Compiler GJC translates Generic Java Programs into Java bytecodes. It is meant to be a drop-in replacement for javac, with exactly the same functionality.

GJC is written in Generic Java. It compiles either conventional or generic Java Programs. The Generic Java extensions are enabled by setting a command line option ( -gj ).

GJC translates by default into Java bytecodes. There is a command line option (-s) which makes GJC emit conventional Java source code instead. Generally, the generated code corresponds to what a human programmer would have done to emulate the extensions of Generic Java. Therefore, the source output option of Generic Java is a convienient way to convert the compiler itself into a standard Java format.

GJC has been written from scratch, with the experience gained from the EspressoGrinder and Pizza compilers. Great emphasis was put on a simple and clear design and a concise implementation which faithfully follows the Java spec.

GJC has been designed to be highly flexible and modular, so that the compiler itself, or some of its components, can be used in a variety of settings. This is reflected in a layered package structure which allows lower-level packages to be used without cooperation of higher-level packages.

GJC is completely functorized, without any global static data structures at all. This makes it easy to embed GJC in large software development environments where several projects can be run concurrently.

Package Structure

GJC package names have the structure gjc.vX.P where gjc is the common prefix, the X stands for the current version number (currently, X = 3), and P stands for the package's name. For simplicity, we will omit the version part of package names in the rest of this description.

The packages of GJC form a layered structure, with classes in higher level layers only needing the services of classes of the same or lower layers. Progressing from bottom to top, the layers are:



Martin Odersky
Mon Nov 2 16:51:36 CST 1998