A useful tool to know about is the javap command. With javap, you can print a description of a compiled class. You don’t need the source code, and you don’t even need to know exactly where it is, only that it is in your classpath. For example:
% javap java.util.Stack
prints the information about the java.util.Stack class:
Compiled from "Stack.java"
public class java.util.Stack<E> extends java.util.Vector<E> {
public java.util.Stack();
public E push(E);
public synchronized E pop();
public synchronized E peek();
public boolean empty();
public synchronized int search(java.lang.Object);
}
This is very useful if you don’t have other documentation handy and can also be helpful
in debugging classpath problems. Using javap, you can determine whether a class is in
the classpath and possibly even which version you are looking at (many classpath issues
involve duplicate classes in the classpath). If you are really curious, you can try javap
with the -c option, which causes it to also print the JVM instructions for each method
in the class!
0 comments:
Post a Comment