GJ

Home
Mirrors
Distribution
Documents
Applications
People
Related
FAQ

A Generic Java Language Extension

Distribution

Current compiler version: 0.6m

Download GJ for your platform

Documentation for the following is available below.

Mailing lists

There are two mailing lists, which are also used for Pizza: a low-volume list for announcements, and a list for public discussion of the compiler and language. Past mailings are kept in an archive.

GJ collection library

The distribution includes a generic version of the Java Collection Library.

The 1.1 release includes the Sun collection libraries for JDK 1.1.6 (in the package com.sun.java.util.collections). The 1.2 release includes this plus the collection libraries for JDK 1.2 beta 4 (in the packages java.lang and java.util). The distribution includes source, binary classes produced with the retrofitter, and documentation produced with the documentation generator.

The distribution also includes some utility classes, in the package gj.util.

  • Browse documentation for gj.util.
The distribution includes source, binary classes, and documentation produced by the documentation generator.


The GJ compiler

The GJ compiler gjc can be used as a drop-in replacement for javac. Like javac, but unlike the Pizza compiler, gjc also supports dynamic compilation of library classes.

The gjc command takes options followed by any number of file names, which must have a .java extension.

  gjc (options) file_1.java ... file_n.java
The following options are supported:

-classpath <pathname> Indicate where to search for class files.
-d <dirname> Indicate output directory for generated class or source files
-experimental Enable experimental features (currently there are none)
-g Emit debug information about local variables and line numbers
-1.1 Accept only standard Java 1.1 input (not yet implemented)
-moreinfo Emit extended information about type errors. This will affix unique numbers to the names of type variables, so that different type variables with the same names can be distinuished from each other. Analogously, this will label anonymous inner classes with unique numbers.
-nowarn Suppress all warning messages.
-prompt Stop after each error.
-retrofit <pathname> retrofit existing classfiles with generic types (see below).
-s Emit standard java sources (with extension .java) instead of class files.
-scramble Replace all private identifiers in emitted classfiles with scrambled names.
-scrambleall Replace all private and package-visible identifiers in emitted classfiles with scrambled names. This makes sense only if all files of a package are compiled together.
-switchcheck Emit a warning if control can fall through from one switch label block to the next. Do not warn if the first switch block is empty. Example: 
  switch (x) {
  case 1: System.out.println("one");
  case 2: System.out.println("two");
  }
yields 
  case 2: System.out.println("two");
  ^ warning: Possible fall-through from case
On the other hand, 
  switch (x) {
  case 1: 
  case 2: System.out.println("one or two");
  }
will not cause a warning. 
-scramble
-unchecked The GJ compiler will normally emit "unchecked" warning messages to flag instances where generic types and raw types are mixed in a fashion that potentially undermines the type rules of GJ. The -unchecked option suppresses these warning messages.
-verbose Verbose output.
-version print version number and release date

The options -depend and -O that are supported by javac are presently not recognized by gjc.


The GJ retrofitter

The GJ retrofitter allows one to attach generic types to prexisting class files. It can in this way retro-actively parameterize classes and their methods which have been written in the conventional Java language. The retrofitter is invoked by setting a special option of the gjc compiler: 

  gjc -retrofit  <pathname> file(s).java
This will compile the given source file(s) in the usual way, but without generating any code. The only other difference between retrofit mode and normal mode is that in retrofit mode method bodies can be omitted.

The retrofitter will then search for classes with the same fully qualified names as those that were compiled, using the <pathname> argument to -retrofit as class path. The tool will check that the erasure of all generic signatures in the compiled classes match with signatures in the loaded classes. If this check succeeds, the loaded classes are augmented with additional attributes that describe their generic types and the augmented class files are written to disk. The usual compiler option -d for setting an output directory applies.


GJ documentation generation

The GJ compiler currently does not support HTML documentation generation in the style of javadoc. However, you can use the pizzadoc tool to generate HTML documents for GJ files as well. You'll need to have the Pizza compiler version 0.39e or later to do this, which is available for download.


Comments and bug reports to the Pizza Group, pizza@cis.unisa.edu.au. Java is a trademark of Sun Microsystems. All software and documents on the Pizza site are © Copyright 1996, 1997 by the respective authors as attributed on each. Terms for redistribution are available.