Package org.objectweb.asm.util
Class Textifier
- java.lang.Object
-
- org.objectweb.asm.util.Printer
-
- org.objectweb.asm.util.Textifier
-
-
Field Summary
Fields Modifier and Type Field Description static intCLASS_DECLARATIONConstant used inappendDescriptorfor class signatures, formatted in default Java notation (non-bytecode)static intCLASS_SIGNATUREConstant used inappendDescriptorfor class signatures, formatted in bytecode notationstatic intFIELD_DESCRIPTORConstant used inappendDescriptorfor field descriptors, formatted in bytecode notationstatic intFIELD_SIGNATUREConstant used inappendDescriptorfor field signatures, formatted in bytecode notationstatic intHANDLE_DESCRIPTORConstant used inappendDescriptorfor handle descriptors, formatted in bytecode notationstatic intINTERNAL_NAMEConstant used inappendDescriptorfor internal type names in bytecode notation.protected Map<Label,String>labelNamesThe label names.protected StringltabTab for labels.static intMETHOD_DESCRIPTORConstant used inappendDescriptorfor method descriptors, formatted in bytecode notationstatic intMETHOD_SIGNATUREConstant used inappendDescriptorfor method signatures, formatted in bytecode notationstatic intPARAMETERS_DECLARATIONConstant used inappendDescriptorfor method parameter signatures, formatted in default Java notation (non-bytecode)protected StringtabTab for class members.protected Stringtab2Tab for bytecode instructions.protected Stringtab3Tab for table and lookup switch instructions.static intTYPE_DECLARATIONConstant used inappendDescriptorfor field or method return value signatures, formatted in default Java notation (non-bytecode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidappendDescriptor(int type, String desc)Appends an internal name, a type descriptor or a type signature tobuf.protected voidappendHandle(Handle h)Appends the information about the given handle tobuf.protected voidappendLabel(Label l)Appends the name of the given label tobuf.protected TextifiercreateTextifier()Creates a new TraceVisitor instance.static voidmain(String[] args)Prints a disassembled view of the given class to the standard output.voidvisit(int version, int access, String name, String signature, String superName, String[] interfaces)Class header.voidvisit(String name, Object value)Annotation value.TextifiervisitAnnotation(String desc, boolean visible)Prints a disassembled view of the given annotation.TextifiervisitAnnotation(String name, String desc)Nested annotation value.TextifiervisitAnnotationDefault()Method default annotation.voidvisitAnnotationEnd()Annotation end.TextifiervisitArray(String name)Annotation array value.voidvisitAttribute(Attribute attr)Prints a disassembled view of the given attribute.TextifiervisitClassAnnotation(String desc, boolean visible)Class annotation.voidvisitClassAttribute(Attribute attr)Class attribute.voidvisitClassEnd()Class end.PrintervisitClassTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Class type annotation.voidvisitCode()Method start.voidvisitEnum(String name, String desc, String value)Annotation enum value.TextifiervisitField(int access, String name, String desc, String signature, Object value)Class field.TextifiervisitFieldAnnotation(String desc, boolean visible)Field annotation.voidvisitFieldAttribute(Attribute attr)Field attribute.voidvisitFieldEnd()Field end.voidvisitFieldInsn(int opcode, String owner, String name, String desc)Method instruction.PrintervisitFieldTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Field type annotation.voidvisitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)Method stack frame.voidvisitIincInsn(int var, int increment)Method instruction.voidvisitInnerClass(String name, String outerName, String innerName, int access)Class inner name.voidvisitInsn(int opcode)Method instruction.PrintervisitInsnAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Instruction type annotation.voidvisitIntInsn(int opcode, int operand)Method instruction.voidvisitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs)Method instruction.voidvisitJumpInsn(int opcode, Label label)Method instruction.voidvisitLabel(Label label)Method label.voidvisitLdcInsn(Object cst)Method instruction.voidvisitLineNumber(int line, Label start)Method debug info.voidvisitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)Method debug info.PrintervisitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible)Local variable type annotation.voidvisitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)Method instruction.voidvisitMaxs(int maxStack, int maxLocals)Method max stack and max locals.TextifiervisitMethod(int access, String name, String desc, String signature, String[] exceptions)Class method.TextifiervisitMethodAnnotation(String desc, boolean visible)Method annotation.voidvisitMethodAttribute(Attribute attr)Method attribute.voidvisitMethodEnd()Method end.voidvisitMethodInsn(int opcode, String owner, String name, String desc)Deprecated.voidvisitMethodInsn(int opcode, String owner, String name, String desc, boolean itf)Method instruction.PrintervisitMethodTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Method type annotation.voidvisitMultiANewArrayInsn(String desc, int dims)Method instruction.voidvisitOuterClass(String owner, String name, String desc)Class outer class.voidvisitParameter(String name, int access)Method parameter.TextifiervisitParameterAnnotation(int parameter, String desc, boolean visible)Method parameter annotation.voidvisitSource(String file, String debug)Class source.voidvisitTableSwitchInsn(int min, int max, Label dflt, Label... labels)Method instruction.PrintervisitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Try catch block type annotation.voidvisitTryCatchBlock(Label start, Label end, Label handler, String type)Method exception handler.TextifiervisitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Prints a disassembled view of the given type annotation.voidvisitTypeInsn(int opcode, String type)Method instruction.voidvisitVarInsn(int opcode, int var)Method instruction.-
Methods inherited from class org.objectweb.asm.util.Printer
appendString, getText, print
-
-
-
-
Field Detail
-
INTERNAL_NAME
public static final int INTERNAL_NAME
Constant used inappendDescriptorfor internal type names in bytecode notation.- See Also:
- Constant Field Values
-
FIELD_DESCRIPTOR
public static final int FIELD_DESCRIPTOR
Constant used inappendDescriptorfor field descriptors, formatted in bytecode notation- See Also:
- Constant Field Values
-
FIELD_SIGNATURE
public static final int FIELD_SIGNATURE
Constant used inappendDescriptorfor field signatures, formatted in bytecode notation- See Also:
- Constant Field Values
-
METHOD_DESCRIPTOR
public static final int METHOD_DESCRIPTOR
Constant used inappendDescriptorfor method descriptors, formatted in bytecode notation- See Also:
- Constant Field Values
-
METHOD_SIGNATURE
public static final int METHOD_SIGNATURE
Constant used inappendDescriptorfor method signatures, formatted in bytecode notation- See Also:
- Constant Field Values
-
CLASS_SIGNATURE
public static final int CLASS_SIGNATURE
Constant used inappendDescriptorfor class signatures, formatted in bytecode notation- See Also:
- Constant Field Values
-
TYPE_DECLARATION
public static final int TYPE_DECLARATION
Constant used inappendDescriptorfor field or method return value signatures, formatted in default Java notation (non-bytecode)- See Also:
- Constant Field Values
-
CLASS_DECLARATION
public static final int CLASS_DECLARATION
Constant used inappendDescriptorfor class signatures, formatted in default Java notation (non-bytecode)- See Also:
- Constant Field Values
-
PARAMETERS_DECLARATION
public static final int PARAMETERS_DECLARATION
Constant used inappendDescriptorfor method parameter signatures, formatted in default Java notation (non-bytecode)- See Also:
- Constant Field Values
-
HANDLE_DESCRIPTOR
public static final int HANDLE_DESCRIPTOR
Constant used inappendDescriptorfor handle descriptors, formatted in bytecode notation- See Also:
- Constant Field Values
-
tab
protected String tab
Tab for class members.
-
tab2
protected String tab2
Tab for bytecode instructions.
-
tab3
protected String tab3
Tab for table and lookup switch instructions.
-
ltab
protected String ltab
Tab for labels.
-
-
Constructor Detail
-
Textifier
public Textifier()
Constructs a newTextifier. Subclasses must not use this constructor. Instead, they must use theTextifier(int)version.- Throws:
IllegalStateException- If a subclass calls this constructor.
-
Textifier
protected Textifier(int api)
Constructs a newTextifier.- Parameters:
api- the ASM API version implemented by this visitor. Must be one ofOpcodes.ASM4orOpcodes.ASM5.
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Prints a disassembled view of the given class to the standard output.Usage: Textifier [-debug] <binary class name or class file name >
- Parameters:
args- the command line arguments.- Throws:
Exception- if the class cannot be found, or if an IO exception occurs.
-
visit
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)Description copied from class:Printer
-
visitSource
public void visitSource(String file, String debug)
Description copied from class:PrinterClass source. SeeClassVisitor.visitSource(java.lang.String, java.lang.String).- Specified by:
visitSourcein classPrinter
-
visitOuterClass
public void visitOuterClass(String owner, String name, String desc)
Description copied from class:PrinterClass outer class. SeeClassVisitor.visitOuterClass(java.lang.String, java.lang.String, java.lang.String).- Specified by:
visitOuterClassin classPrinter
-
visitClassAnnotation
public Textifier visitClassAnnotation(String desc, boolean visible)
Description copied from class:PrinterClass annotation. SeeClassVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitClassAnnotationin classPrinter
-
visitClassTypeAnnotation
public Printer visitClassTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Description copied from class:PrinterClass type annotation. SeeClassVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitClassTypeAnnotationin classPrinter
-
visitClassAttribute
public void visitClassAttribute(Attribute attr)
Description copied from class:PrinterClass attribute. SeeClassVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitClassAttributein classPrinter
-
visitInnerClass
public void visitInnerClass(String name, String outerName, String innerName, int access)
Description copied from class:PrinterClass inner name. SeeClassVisitor.visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int).- Specified by:
visitInnerClassin classPrinter
-
visitField
public Textifier visitField(int access, String name, String desc, String signature, Object value)
Description copied from class:PrinterClass field. SeeClassVisitor.visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object).- Specified by:
visitFieldin classPrinter
-
visitMethod
public Textifier visitMethod(int access, String name, String desc, String signature, String[] exceptions)
Description copied from class:PrinterClass method. SeeClassVisitor.visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]).- Specified by:
visitMethodin classPrinter
-
visitClassEnd
public void visitClassEnd()
Description copied from class:PrinterClass end. SeeClassVisitor.visitEnd().- Specified by:
visitClassEndin classPrinter
-
visit
public void visit(String name, Object value)
Description copied from class:PrinterAnnotation value. SeeAnnotationVisitor.visit(java.lang.String, java.lang.Object).
-
visitEnum
public void visitEnum(String name, String desc, String value)
Description copied from class:PrinterAnnotation enum value. SeeAnnotationVisitor.visitEnum(java.lang.String, java.lang.String, java.lang.String).
-
visitAnnotation
public Textifier visitAnnotation(String name, String desc)
Description copied from class:PrinterNested annotation value. SeeAnnotationVisitor.visitAnnotation(java.lang.String, java.lang.String).- Specified by:
visitAnnotationin classPrinter
-
visitArray
public Textifier visitArray(String name)
Description copied from class:PrinterAnnotation array value. SeeAnnotationVisitor.visitArray(java.lang.String).- Specified by:
visitArrayin classPrinter
-
visitAnnotationEnd
public void visitAnnotationEnd()
Description copied from class:PrinterAnnotation end. SeeAnnotationVisitor.visitEnd().- Specified by:
visitAnnotationEndin classPrinter
-
visitFieldAnnotation
public Textifier visitFieldAnnotation(String desc, boolean visible)
Description copied from class:PrinterField annotation. SeeFieldVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitFieldAnnotationin classPrinter
-
visitFieldTypeAnnotation
public Printer visitFieldTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Description copied from class:PrinterField type annotation. SeeFieldVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitFieldTypeAnnotationin classPrinter
-
visitFieldAttribute
public void visitFieldAttribute(Attribute attr)
Description copied from class:PrinterField attribute. SeeFieldVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitFieldAttributein classPrinter
-
visitFieldEnd
public void visitFieldEnd()
Description copied from class:PrinterField end. SeeFieldVisitor.visitEnd().- Specified by:
visitFieldEndin classPrinter
-
visitParameter
public void visitParameter(String name, int access)
Description copied from class:PrinterMethod parameter. SeeMethodVisitor.visitParameter(String, int).- Overrides:
visitParameterin classPrinter
-
visitAnnotationDefault
public Textifier visitAnnotationDefault()
Description copied from class:PrinterMethod default annotation. SeeMethodVisitor.visitAnnotationDefault().- Specified by:
visitAnnotationDefaultin classPrinter
-
visitMethodAnnotation
public Textifier visitMethodAnnotation(String desc, boolean visible)
Description copied from class:PrinterMethod annotation. SeeMethodVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitMethodAnnotationin classPrinter
-
visitMethodTypeAnnotation
public Printer visitMethodTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Description copied from class:PrinterMethod type annotation. SeeMethodVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitMethodTypeAnnotationin classPrinter
-
visitParameterAnnotation
public Textifier visitParameterAnnotation(int parameter, String desc, boolean visible)
Description copied from class:PrinterMethod parameter annotation. SeeMethodVisitor.visitParameterAnnotation(int, java.lang.String, boolean).- Specified by:
visitParameterAnnotationin classPrinter
-
visitMethodAttribute
public void visitMethodAttribute(Attribute attr)
Description copied from class:PrinterMethod attribute. SeeMethodVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitMethodAttributein classPrinter
-
visitCode
public void visitCode()
Description copied from class:PrinterMethod start. SeeMethodVisitor.visitCode().
-
visitFrame
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)Description copied from class:PrinterMethod stack frame. SeeMethodVisitor.visitFrame(int, int, java.lang.Object[], int, java.lang.Object[]).- Specified by:
visitFramein classPrinter
-
visitInsn
public void visitInsn(int opcode)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitInsn(int).
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitIntInsn(int, int).- Specified by:
visitIntInsnin classPrinter
-
visitVarInsn
public void visitVarInsn(int opcode, int var)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitVarInsn(int, int).- Specified by:
visitVarInsnin classPrinter
-
visitTypeInsn
public void visitTypeInsn(int opcode, String type)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitTypeInsn(int, java.lang.String).- Specified by:
visitTypeInsnin classPrinter
-
visitFieldInsn
public void visitFieldInsn(int opcode, String owner, String name, String desc)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String).- Specified by:
visitFieldInsnin classPrinter
-
visitMethodInsn
@Deprecated public void visitMethodInsn(int opcode, String owner, String name, String desc)
Deprecated.Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String).- Overrides:
visitMethodInsnin classPrinter
-
visitMethodInsn
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String).- Overrides:
visitMethodInsnin classPrinter
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitInvokeDynamicInsn(java.lang.String, java.lang.String, org.objectweb.asm.Handle, java.lang.Object...).- Specified by:
visitInvokeDynamicInsnin classPrinter
-
visitJumpInsn
public void visitJumpInsn(int opcode, Label label)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitJumpInsn(int, org.objectweb.asm.Label).- Specified by:
visitJumpInsnin classPrinter
-
visitLabel
public void visitLabel(Label label)
Description copied from class:PrinterMethod label. SeeMethodVisitor.visitLabel(org.objectweb.asm.Label).- Specified by:
visitLabelin classPrinter
-
visitLdcInsn
public void visitLdcInsn(Object cst)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitLdcInsn(java.lang.Object).- Specified by:
visitLdcInsnin classPrinter
-
visitIincInsn
public void visitIincInsn(int var, int increment)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitIincInsn(int, int).- Specified by:
visitIincInsnin classPrinter
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitTableSwitchInsn(int, int, org.objectweb.asm.Label, org.objectweb.asm.Label...).- Specified by:
visitTableSwitchInsnin classPrinter
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitLookupSwitchInsn(org.objectweb.asm.Label, int[], org.objectweb.asm.Label[]).- Specified by:
visitLookupSwitchInsnin classPrinter
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(String desc, int dims)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitMultiANewArrayInsn(java.lang.String, int).- Specified by:
visitMultiANewArrayInsnin classPrinter
-
visitInsnAnnotation
public Printer visitInsnAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Description copied from class:PrinterInstruction type annotation. SeeMethodVisitor.visitInsnAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitInsnAnnotationin classPrinter
-
visitTryCatchBlock
public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
Description copied from class:PrinterMethod exception handler. SeeMethodVisitor.visitTryCatchBlock(org.objectweb.asm.Label, org.objectweb.asm.Label, org.objectweb.asm.Label, java.lang.String).- Specified by:
visitTryCatchBlockin classPrinter
-
visitTryCatchAnnotation
public Printer visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Description copied from class:PrinterTry catch block type annotation. SeeMethodVisitor.visitTryCatchAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitTryCatchAnnotationin classPrinter
-
visitLocalVariable
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)
Description copied from class:PrinterMethod debug info. SeeMethodVisitor.visitLocalVariable(java.lang.String, java.lang.String, java.lang.String, org.objectweb.asm.Label, org.objectweb.asm.Label, int).- Specified by:
visitLocalVariablein classPrinter
-
visitLocalVariableAnnotation
public Printer visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible)
Description copied from class:PrinterLocal variable type annotation. SeeMethodVisitor.visitTryCatchAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean).- Overrides:
visitLocalVariableAnnotationin classPrinter
-
visitLineNumber
public void visitLineNumber(int line, Label start)Description copied from class:PrinterMethod debug info. SeeMethodVisitor.visitLineNumber(int, org.objectweb.asm.Label).- Specified by:
visitLineNumberin classPrinter
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals)Description copied from class:PrinterMethod max stack and max locals. SeeMethodVisitor.visitMaxs(int, int).
-
visitMethodEnd
public void visitMethodEnd()
Description copied from class:PrinterMethod end. SeeMethodVisitor.visitEnd().- Specified by:
visitMethodEndin classPrinter
-
visitAnnotation
public Textifier visitAnnotation(String desc, boolean visible)
Prints a disassembled view of the given annotation.- Parameters:
desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- a visitor to visit the annotation values.
-
visitTypeAnnotation
public Textifier visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
Prints a disassembled view of the given type annotation.- Parameters:
typeRef- a reference to the annotated type. SeeTypeReference.typePath- the path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be null if the annotation targets 'typeRef' as a whole.desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- a visitor to visit the annotation values.
-
visitAttribute
public void visitAttribute(Attribute attr)
Prints a disassembled view of the given attribute.- Parameters:
attr- an attribute.
-
createTextifier
protected Textifier createTextifier()
Creates a new TraceVisitor instance.- Returns:
- a new TraceVisitor.
-
appendDescriptor
protected void appendDescriptor(int type, String desc)Appends an internal name, a type descriptor or a type signature tobuf.- Parameters:
type- indicates if desc is an internal name, a field descriptor, a method descriptor, a class signature, ...desc- an internal name, type descriptor, or type signature. May be null.
-
appendLabel
protected void appendLabel(Label l)
Appends the name of the given label tobuf. Creates a new label name if the given label does not yet have one.- Parameters:
l- a label.
-
-