Presents your JAVA E-NEWSLETTER for August 5, 2002 <-------------------------------------------> USE JAVAP FOR MORE THAN JUST DOCUMENTATION Javadoc allows you to view documentation on Java, but it's primarily aimed towards Web clients. Fortunately, there are other ways to see documentation on Java, such as the javap command. Javap is a Java class dissassembler. It can disassemble a class file into a bytecode representation, which gives you some understanding of what an implementation is doing without actually decompiling it. Unlike javadoc, it uses the class file and not the source file. This means you can use it on the classes in a jar without having any source available. The standard way to run javap is to type: javap on the command line. For example: javap java.lang.Object will output the following: Compiled from Object.java public class java.lang.Object { public java.lang.Object( ); public final native java.lang.Class getClass( ); public native int hashCode( ); public boolean equals(java.lang.Object); protected native java.lang.Object clone( ) throws java.lang.CloneNotSupportedException; public java.lang.String toString( ); public final native void notify( ); public final native void notifyAll( ); public final native void wait(long) throws java.lang.InterruptedException; public final void wait(long, int) throws java.lang.InterruptedException; public final void wait( ) throws java.lang.InterruptedException; protected void finalize( ) throws java.lang.Throwable; static { }; } Disassembling code can prove to be useful, such as when the Object.wait( ) method is run through 'javap -c': Method void wait( ) 0 aload_0 1 lconst_0 2 invokevirtual #16 5 return Without even having any great understanding of the disassembled code, it's easy to see that Object.wait( ) simply calls Object.wait(long). However, the actual value that's passed to the wait(long) method is not available. While disassembling is a useful feature, the most common usage of javap is as a quick, easy way to see what methods are available on a class. Even with the source and javadoc available, it's often easier to use javap from the command line. ----------------------------------------