The Java Secrets CD

[ Cafe au Lait | Java Secrets | Table of Contents | Examples | About the CD | Corrections | Order ]

The Java Secrets CD contains Java development tools I found intriguing. What unifies my choices is that they all work at a very low level. This isn't just another collection of applets and publisher's editions. Instead it's full of hardcore hacking tools for Java. As such some of these tools are a little rough-edged. I advise caution when using them. Nonetheless I've found them all to be useful and thought-provoking.

When you put them all together you've got both the foundations of an almost complete Java environment, (runtime, compilers, etc.) and a complete package for reverse engineering Java files (decompiler, disassembler, class browser, etc.) A lot of these tools are GPL'd (published under the Free Software Foundation's General Public License) and thus in many cases source code is included. Even if you don't replace your Sun supplied compilers and runtimes with these versions, you can still learn a lot about Java by studying the source code for these programs.

The one piece I was not able to include on the CD that I really, really wanted was an independent implementation of the AWT with source code. However I do suggest you check out http://www.biss-net.com/biss-awt.html to learn about the BISS AWT package. While you're at it you should also learn about the Jolt project, http://www.redhat.com/linux-info/jolt/, that's attempting to produce a freely redistributable, clean-room clone of Java using many of the pieces on this very CD.

I also hoped to include the complete source code for Sun's Java here as well. Regrettably before Javasoft would even agree to talk to me about licensing their source code, they insisted that I sign a non-disclosure agreement (NDA) that would have made writing this book impossible. However, the standard JDK does include the source code for at least the java packages. Unzip the src.zip file in the main JDK directory.

The tools you will find on this disk include David Engberg's guavac compiler, Tim Wilkinson's Kaffe virtual machine and JIT, Robert Raud's ClassViewer class browser, Aart Bik's JAVAR thread optimizer, Wingsoft's Wingdis decompiler, PFP Software GmbH's DeJAVA disassembler, and KB Sriram's Hashjava obfuscator, Jas byte code assembler, and Jinstall installer maker. I've also included Per Bothner's Kawa Scheme compiler that outputs Java byte code and Colin J. Taylor's Java Lambda Calculus Interpreter that's written entirely in Java.

These tools are all included on the disk in uncompressed, unarchived form. Where you find a zip file, it is an uncompressed zip file that stores a Java package or packages that you should place in your class path. This CD mounts on Windows 95 and NT 4.0, the MacOS, and Solaris. In all cases you should mount the CD in the usual fashion for your OS, and then copy the directories you're interested in onto your hard drive. These directories are:

There is also a SOURCE directory which contains source code from this book and a README file which is essentially this appendix. Information about the specific packages follows.

Guavac 0.3 is a Java compiler written in C++ by Effective Edge Technologies and distributed under the Gnu General Public License. You should feel free to use, copy and modify it, based on the terms in the COPYING file included in this distribution. Guavac is distributed free of charge in the hopes that other people will find it useful and possibly enhance its utility in turn.

Guavac should produce correct byte code for valid Java input, but you may encounter some difficulties in compiling guavac itself, which may make guavac impractical for inexperienced programmers. Guavac is written in C++, so it requires a decent C++ compiler and a class library that implements the standard C++ libraries defined in the current C++ standard. To be more specific, guavac uses a few STL collection classes (like map and deque) as well as the standard string class which is used for Java's 16-bit (Unicode) strings. This has only been tested using gcc (version 2.7.2) and libg++ (version 2.7.1), which seem to work out of the box on Linux, OSF, Irix and Solaris. Older versions of gcc will NOT work. The C++ code used should be reasonably portable to an alternate C++ compiler that also supports the standard templates. The only blatantly non-portable code that may require changing is in dynamic_cast.h. Read the comments there for more information. The guavac home page is at http://http.cs.berkeley.edu/~engberg/guavac/

Tim Wilkinson's Kaffe 0.83 is a virtual machine design for most Unix-like systems. Kaffe performs "just-in-time" compilation. If full JIT support isn't possible, the system defaults to an interpreter. The Kaffe home page is at http://www.kaffe.org

Robert Raud's ClassViewer displays the methods and fields defined in a Java .class file. You can browse into other classes referred to in the .class file and decompile the class file if you also have Mocha installed. This is useful when source code is not available and as a verification and troubleshooting tool. Files can be locally stored or downloaded from a website. The Java ClassViewer is written in Java and works on any platform where Java is supported. The ClassViewer home page is at http://www.intac.com/~robraud/classinfo.html

Aart Bik's JAVAR, version 1.2 beta,is a prototype restructuring compiler that can be used to make implicit parallelism in Java programs explicit by means of multi-threading. This prototype tool does not provide a complete Java front-end (for instance, unicode escapes are not supported and only very limited semantic analysis has been implemented). Therefore applying JAVAR to a program should be postponed until after a program has been thoroughly tested using a full Java compiler. Moreover, JAVAR relies completely on the identification of implicit parallelism by means of annotations. However, the tool provides sufficient functionality to make the parallelization less complex and less error-prone. The JAVAR web page can be found at http://www.extreme.indiana.edu/hpjava/

PFP Software GmbH's DeJAVA, version 1.13, is a Windows 95/NT console mode application that disassembles .class byte code files, much like the javap utility that ships with Suns JDK.

Colin J. Taylor's Java Lambda Calculus Interpreter 1.00 is a GPL'd lambda calculus interpreter that uses call-by-name semantics written in Java. The language is mostly Church's simple untyped lambda calculus, the only concession for usefulness is the addition of numbers. (If this sounds like Greek to you, and you don't speak Greek, don't worry; but theoretical computer scientists really do get quite jazzed about this sort of thing.) The Java Lambda Calculus Interpreter home page is at http://www.cs.nott.ac.uk/~cjt/eval/Lambda.html

Per Bothner's Kawa Scheme compiler, version 1.4, compiles R4RS Scheme source code into Java byte code. It provides Scheme access to Java objects, fields, and methods. The gnu.bytecode package is used to generate and manipulate .class files. The Kawa home page is at http://www.cygnus.com/~bothner/kawa.html

KB Sriram's Jinstall 0.1 is an application which packs a directory into a single class file, which can then be run as an application to unpack itself on another machine. In fact, Jinstall itself is distributed as a Jinstall class. To unpack it, copy the install.class file to your hard drive and run "java install" from the command line. The JInstall home page is at http://www.sbktech.org/jinstall.html

KB Sriram's Hashjava 0.3 is a Java package which obfuscates symbols in your bytecode, making it a little harder to decompile. The Hashjava home page is at http://www.sbktech.org/hashjava.html Hashjava is distributed as a jinstall class. To install it copy the hjinstall.class file onto your hard drive, and run "java hjinstall".

KB Sriram's Jas 0.4 is a java package to generate java bytecode. It includes a scheme like scripting language to drive the package and generate bytecode. The Jas home page is at http://www.sbktech.org/jas.html

WingDis 2.0.3 is a command-line decompiler which allows users to convert a Java class or Java byte code file to a Java-like program. The eventual goal of WingDis is to generate an equivalent and compilable Java source code (text) from a Java class file (binary). It can help users recover accidently removed source code or explore public interfaces. WingDis is a payware program, specially licensed for this book. Please do not redistribute it. A coupon is included in the text for an upgrade to the latest version.

Founded in October, 1995 at Fremont, California, WingSoft Company specializes in Java-based products and services. Since its inception, WingSoft has developed serveral Java-based products including WingDis, WingEditor (a simple Java-development environment), WingFtp (a powerful FTP Client), and WingDBR (a database replication and synchronization tool). WingSoft also provides consulting and contractor services in the San Francisco Bay Area. The Wingsoft home page is at http://www.wingsoft.com/

Finally, all the source code for the examples in this book is included. Please feel free to reuse any or all of this source code in your own projects. No specific permission is necessary or required.


[ Cafe au Lait | Java Secrets | Table of Contents | Examples | About the CD | Corrections | Order ]

Copyright 1995-1997 Elliotte Rusty Harold
elharo@sunsite.unc.edu
Last Modified November 5, 1997