Using siggen

siggen has two main uses: (1) converting Java programs into Jif programs, and (2) incremental development in Jif.

Converting Java programs

At present, converting Java programs into Jif programs is difficult for a lot of different reasons: number of errors, no good tools, uncertainty about program structure. One of the things that siggen can do is automatically determine the endpoints of a Java program.

The Wallet example uses five classes from the Java Card framework -- however, which methods and fields does it use from that class? Naively generating signatures by hand and adding methods as necessary is tedious and may depart from the semantics of the actual library (for example, by selecting a subclass instead of a superclass as the type of a method argument).

siggen uses polyglot's ability to parse and type-check a Java extension class to (i) determine exactly what methods and fields from external classes a program uses, and (ii) output this information as a "skeleton" Java file.

If you are using siggen on files with a .java extension, be sure and add the argument -sx java to your command line. By default, polyglot operates on files with a .jl extension.

Incremental Development in Jif

A secondary use of siggen is in generating the signatures for a Jif program as it is developed. For example, suppose we need to add the functionality of a KeyFactory to a currently compiled Jif program. To use siggen for this, we can add an import statement to our Jif program, write some code that

One way to verify that the Java code you have written is correct without doing any label checking is to give jifc the additional arguments:

jifc -disable LabelCheckPass -nooutput (file name)

This will type check your program, but not label check it. Once your program is type-correct, you can generate the signature files using siggen, manually label and compile them, and then add them to your signature classpath.

Back


Dave King
Last modified: Mon Dec 3 18:19:49 EST 2007