Package org.objectweb.asm.util
Class ASMifier
- java.lang.Object
-
- org.objectweb.asm.util.Printer
-
- org.objectweb.asm.util.ASMifier
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidappendConstant(Object cst)Appends a string representation of the given constant to the given buffer.protected voidappendLabel(Label l)Appends the name of the given label tobuf.protected ASMifiercreateASMifier(String name, int id)protected voiddeclareLabel(Label l)Appends a declaration of the given label tobuf.static voidmain(String[] args)Prints the ASM source code to generate 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.ASMifiervisitAnnotation(String desc, boolean visible)ASMifiervisitAnnotation(String name, String desc)Nested annotation value.ASMifiervisitAnnotationDefault()Method default annotation.voidvisitAnnotationEnd()Annotation end.ASMifiervisitArray(String name)Annotation array value.voidvisitAttribute(Attribute attr)ASMifiervisitClassAnnotation(String desc, boolean visible)Class annotation.voidvisitClassAttribute(Attribute attr)Class attribute.voidvisitClassEnd()Class end.ASMifiervisitClassTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)Class type annotation.voidvisitCode()Method start.voidvisitEnum(String name, String desc, String value)Annotation enum value.ASMifiervisitField(int access, String name, String desc, String signature, Object value)Class field.ASMifiervisitFieldAnnotation(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.ASMifiervisitFieldTypeAnnotation(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.ASMifiervisitInsnAnnotation(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.ASMifiervisitMethod(int access, String name, String desc, String signature, String[] exceptions)Class method.ASMifiervisitMethodAnnotation(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.ASMifiervisitMethodTypeAnnotation(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 parameterName, int access)Method parameter.ASMifiervisitParameterAnnotation(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.ASMifiervisitTryCatchAnnotation(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.ASMifiervisitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)ASMifiervisitTypeAnnotation(String method, int typeRef, TypePath typePath, String desc, boolean visible)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
-
name
protected final String name
The name of the visitor variable in the produced code.
-
id
protected final int id
Identifier of the annotation visitor variable in the produced code.
-
-
Constructor Detail
-
ASMifier
public ASMifier()
Constructs a newASMifier. Subclasses must not use this constructor. Instead, they must use theASMifier(int, String, int)version.- Throws:
IllegalStateException- If a subclass calls this constructor.
-
ASMifier
protected ASMifier(int api, String name, int id)Constructs a newASMifier.- Parameters:
api- the ASM API version implemented by this class. Must be one ofOpcodes.ASM4orOpcodes.ASM5.name- the name of the visitor variable in the produced code.id- identifier of the annotation visitor variable in the produced code.
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Prints the ASM source code to generate the given class to the standard output.Usage: ASMifier [-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 ASMifier visitClassAnnotation(String desc, boolean visible)
Description copied from class:PrinterClass annotation. SeeClassVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitClassAnnotationin classPrinter
-
visitClassTypeAnnotation
public ASMifier 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 ASMifier 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 ASMifier 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 ASMifier 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 ASMifier 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 ASMifier visitFieldAnnotation(String desc, boolean visible)
Description copied from class:PrinterField annotation. SeeFieldVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitFieldAnnotationin classPrinter
-
visitFieldTypeAnnotation
public ASMifier 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 parameterName, int access)
Description copied from class:PrinterMethod parameter. SeeMethodVisitor.visitParameter(String, int).- Overrides:
visitParameterin classPrinter
-
visitAnnotationDefault
public ASMifier visitAnnotationDefault()
Description copied from class:PrinterMethod default annotation. SeeMethodVisitor.visitAnnotationDefault().- Specified by:
visitAnnotationDefaultin classPrinter
-
visitMethodAnnotation
public ASMifier visitMethodAnnotation(String desc, boolean visible)
Description copied from class:PrinterMethod annotation. SeeMethodVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitMethodAnnotationin classPrinter
-
visitMethodTypeAnnotation
public ASMifier 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 ASMifier 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 ASMifier 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 ASMifier 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
-
visitTypeAnnotation
public ASMifier visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible)
-
visitTypeAnnotation
public ASMifier visitTypeAnnotation(String method, int typeRef, TypePath typePath, String desc, boolean visible)
-
visitAttribute
public void visitAttribute(Attribute attr)
-
appendConstant
protected void appendConstant(Object cst)
Appends a string representation of the given constant to the given buffer.
-
declareLabel
protected void declareLabel(Label l)
Appends a declaration of the given label tobuf. This declaration is of the form "Label lXXX = new Label();". Does nothing if the given label has already been declared.- Parameters:
l- a label.
-
-