[Next] [Previous] [Up] [Top]
7 Non-Cecil Front Ends
7.3 Using the Java Front End
Here's some information on how to compile a Java program using Vortex.
- First, run javac on your input Java program to produce .class files. I usually install my application in /projects/cecil/java/src, and then run javac using the following incantation:
- javac -O \ -classpath "/projects/cecil/java/src/<appname>:/projects/cecil/java/src" \ -d /projects/cecil/java/classes/<appname>-classes-O \ /projects/cecil/java/src/<appname>/Main.java [and maybe all the other .java source files]
- Now all the .class files are in /projects/cecil/java/classes/<appname>-O.
- I javac-compile w/ -O to give the best benefit to the competition (does some inlining, and maybe is the only configuration that calls final methods directly), although this blocks incremental recompilation if you change the .java source files (the whole app is recompiled).
- There's a javac program compiled for SunOS (using Vortex!) in the standard place for executables, .../bin/sun4/javac. There's one set up to use the Java interpreter on Solaris, but you have to set up some things to run it.
- If you have your own javelin subtree (cecil-developer/Java), you should set JAVELIN_HOME to that directory, and compile (using make) the javelin front-end program. Otherwise you can do nothing and just get the default JAVELIN_HOME directory in the baseline.
- Now comes some complexity. You make a directory to contain the output RTL files (e.g. ~/vortex/Java/<appname>), and define 4 files in that directory containing one or more lines of text:
- AppName -- the name of the generated executable; `cat AppName`.rtl is the name of the root file produced by Javelin.
- ClassDir -- the place where the class files were put, e.g. /projects/cecil/java/<appname>-classes-O. (This can be a sequence of directory names, separated by colons. ClassDir uses the same format as the classpath option or CLASSPATH environment variable used by javac.)
- MainName -- the Java package name of the root class, using Java's dot-notation instead of slashes, e.g. "<appname>.Main". Note: if the target application isn't in a package, then the right main name will be just the class name containing the main function, e.g. "Main".
- Files -- the Java package names of the classes in the application, e.g. "java.lang.Object", one per line, in the order the classes should be initialized.
- This last file is a pain to produce, since there's no easy way I know of to figure out the implicit dependencies on class initialization. I usually run javac with -verbose, and collect the lines like [wrote ...] from the output to identify the set of classes and an approximation of their order, look at an existing program's order for the standard library classes, and then cross my fingers for the application's order. You can look at the *_clinit functions in the generated .rtl files to check for non-trivial dependencies, too.
- OK, now you're set: run JV-em (in ~/vortex/Java/bin/shell; this should be in your path) to execute javelin on all the source files and produce a lot of .rtl files, headed by <appname>.rtl.
- [Two other scripts are handy if you're modifying the javelin front-end: JV-diff runs the Javelin front-end on all the files and reports differences between the previous files and the new files (it does not overwrite the previous files), and JV-diff-short is the same except it just prints "different" or "same".]
- Finally, start up vortex and do "lang Java; make <appname>.rtl". This should produce an executable named <appname> that is the compiled Java program. Yahoo!
How to Use the Vortex Compiler and Environments - 25 MARCH 1997
[Next] [Previous] [Up] [Top]
Generated with Harlequin WebMaker