org.objectweb.asm.util
Class TraceClassVisitor
- ClassVisitor
public class TraceClassVisitor
A
ClassVisitor
that prints a disassembled view of the classes it
visits. This class visitor can be used alone (see the
main
method) to disassemble a class. It can also be used in the middle of class
visitor chain to trace the class that is visited at a given point in this
chain. This may be uselful for debugging purposes.
The trace printed when
visiting the
Hello class is the following:
// class version 49.0 (49)
// access flags 33
public class Hello {
// compiled from: Hello.java
// access flags 1
public <init> ()V
ALOAD 0
INVOKESPECIAL java/lang/Object <init> ()V
RETURN
MAXSTACK = 1
MAXLOCALS = 1
// access flags 9
public static main ([Ljava/lang/String;)V
GETSTATIC java/lang/System out Ljava/io/PrintStream;
LDC "hello"
INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V
RETURN
MAXSTACK = 2
MAXLOCALS = 1
}
where
Hello is defined by:
public class Hello {
public static void main(String[] args) {
System.out.println("hello");
}
}
- Eric Bruneton
- Eugene Kuleshov
protected ClassVisitor | cv - The
ClassVisitor to which this visitor delegates calls.
|
protected PrintWriter | pw - The print writer to be used to print the class.
|
protected TraceFieldVisitor | createTraceFieldVisitor()
|
protected TraceMethodVisitor | createTraceMethodVisitor()
|
static void | main(String[] args) - Prints a disassembled view of the given class to the standard output.
|
void | visit(int version, int access, String name, String signature, String superName, String[] interfaces)
|
AnnotationVisitor | visitAnnotation(String desc, boolean visible)
|
void | visitAttribute(Attribute attr)
|
void | visitEnd()
|
FieldVisitor | visitField(int access, String name, String desc, String signature, Object value)
|
void | visitInnerClass(String name, String outerName, String innerName, int access)
|
MethodVisitor | visitMethod(int access, String name, String desc, String signature, String[] exceptions)
|
void | visitOuterClass(String owner, String name, String desc)
|
void | visitSource(String file, String debug)
|
pw
protected final PrintWriter pw
The print writer to be used to print the class.
TraceClassVisitor
public TraceClassVisitor(PrintWriter pw)
pw
- the print writer to be used to print the class.
TraceClassVisitor
public TraceClassVisitor(ClassVisitor cv,
PrintWriter pw)
cv
- the ClassVisitor
to which this visitor delegates calls.
May be null.pw
- the print writer to be used to print the class.
main
public static void main(String[] args)
throws Exception
Prints a disassembled view of the given class to the standard output.
Usage: TraceClassVisitor [-debug] <fully qualified class name or class
file name >
args
- the command line arguments.
visit
public void visit(int version,
int access,
String name,
String signature,
String superName,
String[] interfaces)
- visit in interface ClassVisitor
visitInnerClass
public void visitInnerClass(String name,
String outerName,
String innerName,
int access)
- visitInnerClass in interface ClassVisitor