Package org.objectweb.asm.util
Class ASMifier
- java.lang.Object
-
- org.objectweb.asm.util.Printer
-
- org.objectweb.asm.util.ASMifier
-
-
Field Summary
Fields Modifier and Type Field Description protected intidIdentifier of the annotation visitor variable in the produced code.protected java.util.Map<Label,java.lang.String>labelNamesThe label names.protected java.lang.StringnameThe name of the visitor variable in the produced code.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidappendConstant(java.lang.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(java.lang.String name, int id)protected voiddeclareLabel(Label l)Appends a declaration of the given label tobuf.static voidmain(java.lang.String[] args)Prints the ASM source code to generate the given class to the standard output.voidvisit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)Class header.voidvisit(java.lang.String name, java.lang.Object value)Annotation value.ASMifiervisitAnnotation(java.lang.String desc, boolean visible)ASMifiervisitAnnotation(java.lang.String name, java.lang.String desc)Nested annotation value.ASMifiervisitAnnotationDefault()Method default annotation.voidvisitAnnotationEnd()Annotation end.ASMifiervisitArray(java.lang.String name)Annotation array value.voidvisitAttribute(Attribute attr)ASMifiervisitClassAnnotation(java.lang.String desc, boolean visible)Class annotation.voidvisitClassAttribute(Attribute attr)Class attribute.voidvisitClassEnd()Class end.ASMifiervisitClassTypeAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)Class type annotation.voidvisitCode()Method start.voidvisitEnum(java.lang.String name, java.lang.String desc, java.lang.String value)Annotation enum value.ASMifiervisitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)Class field.ASMifiervisitFieldAnnotation(java.lang.String desc, boolean visible)Field annotation.voidvisitFieldAttribute(Attribute attr)Field attribute.voidvisitFieldEnd()Field end.voidvisitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Method instruction.ASMifiervisitFieldTypeAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)Field type annotation.voidvisitFrame(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)Method stack frame.voidvisitIincInsn(int var, int increment)Method instruction.voidvisitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)Class inner name.voidvisitInsn(int opcode)Method instruction.ASMifiervisitInsnAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)Instruction type annotation.voidvisitIntInsn(int opcode, int operand)Method instruction.voidvisitInvokeDynamicInsn(java.lang.String name, java.lang.String desc, Handle bsm, java.lang.Object... bsmArgs)Method instruction.voidvisitJumpInsn(int opcode, Label label)Method jump instruction.voidvisitLabel(Label label)Method label.voidvisitLdcInsn(java.lang.Object cst)Method instruction.voidvisitLineNumber(int line, Label start)Method debug info.voidvisitLocalVariable(java.lang.String name, java.lang.String desc, java.lang.String signature, Label start, Label end, int index)Method debug info.PrintervisitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, java.lang.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, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)Class method.ASMifiervisitMethodAnnotation(java.lang.String desc, boolean visible)Method annotation.voidvisitMethodAttribute(Attribute attr)Method attribute.voidvisitMethodEnd()Method end.voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Deprecated.voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)Method instruction.ASMifiervisitMethodTypeAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)Method type annotation.voidvisitMultiANewArrayInsn(java.lang.String desc, int dims)Method instruction.voidvisitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)Class outer class.voidvisitParameter(java.lang.String parameterName, int access)Method parameter.ASMifiervisitParameterAnnotation(int parameter, java.lang.String desc, boolean visible)Method parameter annotation.voidvisitSource(java.lang.String file, java.lang.String debug)Class source.voidvisitTableSwitchInsn(int min, int max, Label dflt, Label... labels)Method instruction.ASMifiervisitTryCatchAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)Try catch block type annotation.voidvisitTryCatchBlock(Label start, Label end, Label handler, java.lang.String type)Method exception handler.ASMifiervisitTypeAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)ASMifiervisitTypeAnnotation(java.lang.String method, int typeRef, TypePath typePath, java.lang.String desc, boolean visible)voidvisitTypeInsn(int opcode, java.lang.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 java.lang.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.
-
labelNames
protected java.util.Map<Label,java.lang.String> labelNames
The label names. This map associates String values to Label keys. It is used only in ASMifierMethodVisitor.
-
-
Constructor Detail
-
ASMifier
public ASMifier()
Constructs a newASMifier. Subclasses must not use this constructor. Instead, they must use theASMifier(int, String, int)version.- Throws:
java.lang.IllegalStateException- If a subclass calls this constructor.
-
ASMifier
protected ASMifier(int api, java.lang.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(java.lang.String[] args) throws java.lang.ExceptionPrints 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:
java.lang.Exception- if the class cannot be found, or if an IO exception occurs.
-
visit
public void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)Description copied from class:PrinterClass header. SeeClassVisitor.visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]).- Specified by:
visitin classPrinter- Parameters:
version- the class version.access- the class's access flags (seeOpcodes). This parameter also indicates if the class is deprecated.name- the internal name of the class (seegetInternalName).signature- the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.superName- the internal of name of the super class (seegetInternalName). For interfaces, the super class isObject. May be null, but only for theObjectclass.interfaces- the internal names of the class's interfaces (seegetInternalName). May be null.
-
visitSource
public void visitSource(java.lang.String file, java.lang.String debug)Description copied from class:PrinterClass source. SeeClassVisitor.visitSource(java.lang.String, java.lang.String).- Specified by:
visitSourcein classPrinter- Parameters:
file- the name of the source file from which the class was compiled. May be null.debug- additional debug information to compute the correspondance between source and compiled elements of the class. May be null.
-
visitOuterClass
public void visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)Description copied from class:PrinterClass outer class. SeeClassVisitor.visitOuterClass(java.lang.String, java.lang.String, java.lang.String). Visits the enclosing class of the class. This method must be called only if the class has an enclosing class.- Specified by:
visitOuterClassin classPrinter- Parameters:
owner- internal name of the enclosing class of the class.name- the name of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.desc- the descriptor of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
-
visitClassAnnotation
public ASMifier visitClassAnnotation(java.lang.String desc, boolean visible)
Description copied from class:PrinterClass annotation. SeeClassVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitClassAnnotationin classPrinter- Parameters:
desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- the printer
-
visitClassTypeAnnotation
public ASMifier visitClassTypeAnnotation(int typeRef, TypePath typePath, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beCLASS_TYPE_PARAMETER,CLASS_TYPE_PARAMETER_BOUNDorCLASS_EXTENDS. 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:
- the printer
-
visitClassAttribute
public void visitClassAttribute(Attribute attr)
Description copied from class:PrinterClass attribute. SeeClassVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitClassAttributein classPrinter- Parameters:
attr- an attribute.
-
visitInnerClass
public void visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.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- Parameters:
name- the internal name of an inner class (seegetInternalName).outerName- the internal name of the class to which the inner class belongs (seegetInternalName). May be null for not member classes.innerName- the (simple) name of the inner class inside its enclosing class. May be null for anonymous inner classes.access- the access flags of the inner class as originally declared in the enclosing class.
-
visitField
public ASMifier visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.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- Parameters:
access- the field's access flags (seeOpcodes). This parameter also indicates if the field is synthetic and/or deprecated.name- the field's name.desc- the field's descriptor (seeType).signature- the field's signature. May be null if the field's type does not use generic types.value- the field's initial value. This parameter, which may be null if the field does not have an initial value, must be anInteger, aFloat, aLong, aDoubleor aString(for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.- Returns:
- the printer
-
visitMethod
public ASMifier visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.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- Parameters:
access- the method's access flags (seeOpcodes). This parameter also indicates if the method is synthetic and/or deprecated.name- the method's name.desc- the method's descriptor (seeType).signature- the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.exceptions- the internal names of the method's exception classes (seegetInternalName). May be null.- Returns:
- the printer
-
visitClassEnd
public void visitClassEnd()
Description copied from class:PrinterClass end. SeeClassVisitor.visitEnd().- Specified by:
visitClassEndin classPrinter
-
visit
public void visit(java.lang.String name, java.lang.Object value)Description copied from class:PrinterAnnotation value. SeeAnnotationVisitor.visit(java.lang.String, java.lang.Object).- Specified by:
visitin classPrinter- Parameters:
name- the value name.value- the actual value, whose type must beByte,Boolean,Character,Short,Integer,Long,Float,Double,StringorTypeor OBJECT or ARRAY sort. This value can also be an array of byte, boolean, short, char, int, long, float or double values (this is equivalent to usingvisitArrayand visiting each array element in turn, but is more convenient).
-
visitEnum
public void visitEnum(java.lang.String name, java.lang.String desc, java.lang.String value)Description copied from class:PrinterAnnotation enum value. SeeAnnotationVisitor.visitEnum(java.lang.String, java.lang.String, java.lang.String). Visits an enumeration value of the annotation.
-
visitAnnotation
public ASMifier visitAnnotation(java.lang.String name, java.lang.String desc)
Description copied from class:PrinterNested annotation value. SeeAnnotationVisitor.visitAnnotation(java.lang.String, java.lang.String).- Specified by:
visitAnnotationin classPrinter- Parameters:
name- the value name.desc- the class descriptor of the nested annotation class.- Returns:
- the printer
-
visitArray
public ASMifier visitArray(java.lang.String name)
Description copied from class:PrinterAnnotation array value. SeeAnnotationVisitor.visitArray(java.lang.String). Visits an array value of the annotation. Note that arrays of primitive types (such as byte, boolean, short, char, int, long, float or double) can be passed as value tovisit. This is whatClassReaderdoes.- Specified by:
visitArrayin classPrinter- Parameters:
name- the value name.- Returns:
- the printer
-
visitAnnotationEnd
public void visitAnnotationEnd()
Description copied from class:PrinterAnnotation end. SeeAnnotationVisitor.visitEnd().- Specified by:
visitAnnotationEndin classPrinter
-
visitFieldAnnotation
public ASMifier visitFieldAnnotation(java.lang.String desc, boolean visible)
Description copied from class:PrinterField annotation. SeeFieldVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitFieldAnnotationin classPrinter- Parameters:
desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- the printer
-
visitFieldTypeAnnotation
public ASMifier visitFieldTypeAnnotation(int typeRef, TypePath typePath, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beFIELD. 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:
- the printer
-
visitFieldAttribute
public void visitFieldAttribute(Attribute attr)
Description copied from class:PrinterField attribute. SeeFieldVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitFieldAttributein classPrinter- Parameters:
attr- an attribute.
-
visitFieldEnd
public void visitFieldEnd()
Description copied from class:PrinterField end. SeeFieldVisitor.visitEnd().- Specified by:
visitFieldEndin classPrinter
-
visitParameter
public void visitParameter(java.lang.String parameterName, int access)Description copied from class:PrinterMethod parameter. SeeMethodVisitor.visitParameter(String, int).- Overrides:
visitParameterin classPrinter- Parameters:
parameterName- parameter name or null if none is provided.access- the parameter's access flags, only ACC_FINAL, ACC_SYNTHETIC or/and ACC_MANDATED are allowed (seeOpcodes).
-
visitAnnotationDefault
public ASMifier visitAnnotationDefault()
Description copied from class:PrinterMethod default annotation. SeeMethodVisitor.visitAnnotationDefault().- Specified by:
visitAnnotationDefaultin classPrinter- Returns:
- the printer
-
visitMethodAnnotation
public ASMifier visitMethodAnnotation(java.lang.String desc, boolean visible)
Description copied from class:PrinterMethod annotation. SeeMethodVisitor.visitAnnotation(java.lang.String, boolean).- Specified by:
visitMethodAnnotationin classPrinter- Parameters:
desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- the printer
-
visitMethodTypeAnnotation
public ASMifier visitMethodTypeAnnotation(int typeRef, TypePath typePath, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beFIELD. 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:
- the printer
-
visitParameterAnnotation
public ASMifier visitParameterAnnotation(int parameter, java.lang.String desc, boolean visible)
Description copied from class:PrinterMethod parameter annotation. SeeMethodVisitor.visitParameterAnnotation(int, java.lang.String, boolean).- Specified by:
visitParameterAnnotationin classPrinter- Parameters:
parameter- the parameter index.desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- the printer
-
visitMethodAttribute
public void visitMethodAttribute(Attribute attr)
Description copied from class:PrinterMethod attribute. SeeMethodVisitor.visitAttribute(org.objectweb.asm.Attribute).- Specified by:
visitMethodAttributein classPrinter- Parameters:
attr- an attribute.
-
visitCode
public void visitCode()
Description copied from class:PrinterMethod start. SeeMethodVisitor.visitCode().
-
visitFrame
public void visitFrame(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)Description copied from class:PrinterMethod stack frame. SeeMethodVisitor.visitFrame(int, int, java.lang.Object[], int, java.lang.Object[]). Visits the current state of the local variables and operand stack elements. This method must(*) be called just before any instruction i that follows an unconditional branch instruction such as GOTO or THROW, that is the target of a jump instruction, or that starts an exception handler block. The visited types must describe the values of the local variables and of the operand stack elements just before i is executed.
(*) this is mandatory only for classes whose version is greater than or equal toV1_6.
The frames of a method must be given either in expanded form, or in compressed form (all frames must use the same format, i.e. you must not mix expanded and compressed frames within a single method):- In expanded form, all frames must have the F_NEW type.
- In compressed form, frames are basically "deltas" from the state of
the previous frame:
Opcodes.F_SAMErepresenting frame with exactly the same locals as the previous frame and with the empty stack.Opcodes.F_SAME1representing frame with exactly the same locals as the previous frame and with single value on the stack (nStackis 1 andstack[0]contains value for the type of the stack item).Opcodes.F_APPENDrepresenting frame with current locals are the same as the locals in the previous frame, except that additional locals are defined (nLocalis 1, 2 or 3 andlocalelements contains values representing added types).Opcodes.F_CHOPrepresenting frame with current locals are the same as the locals in the previous frame, except that the last 1-3 locals are absent and with the empty stack (nLocalsis 1, 2 or 3).Opcodes.F_FULLrepresenting complete frame data.
In both cases the first frame, corresponding to the method's parameters and access flags, is implicit and must not be visited. Also, it is illegal to visit two or more frames for the same code location (i.e., at least one instruction must be visited between two calls to visitFrame).- Specified by:
visitFramein classPrinter- Parameters:
type- the type of this stack map frame. Must beOpcodes.F_NEWfor expanded frames, orOpcodes.F_FULL,Opcodes.F_APPEND,Opcodes.F_CHOP,Opcodes.F_SAMEorOpcodes.F_APPEND,Opcodes.F_SAME1for compressed frames.nLocal- the number of local variables in the visited frame.local- the local variable types in this frame. This array must not be modified. Primitive types are represented byOpcodes.TOP,Opcodes.INTEGER,Opcodes.FLOAT,Opcodes.LONG,Opcodes.DOUBLE,Opcodes.NULLorOpcodes.UNINITIALIZED_THIS(long and double are represented by a single element). Reference types are represented by String objects (representing internal names), and uninitialized types by Label objects (this label designates the NEW instruction that created this uninitialized value).nStack- the number of operand stack elements in the visited frame.stack- the operand stack types in this frame. This array must not be modified. Its content has the same format as the "local" array.
-
visitInsn
public void visitInsn(int opcode)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitInsn(int)- Specified by:
visitInsnin classPrinter- Parameters:
opcode- the opcode of the instruction to be visited. This opcode is either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, or MONITOREXIT.
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitIntInsn(int, int).- Specified by:
visitIntInsnin classPrinter- Parameters:
opcode- the opcode of the instruction to be visited. This opcode is either BIPUSH, SIPUSH or NEWARRAY.operand- the operand of the instruction to be visited.
When opcode is BIPUSH, operand value should be between Byte.MIN_VALUE and Byte.MAX_VALUE.
When opcode is SIPUSH, operand value should be between Short.MIN_VALUE and Short.MAX_VALUE.
When opcode is NEWARRAY, operand value should be one ofOpcodes.T_BOOLEAN,Opcodes.T_CHAR,Opcodes.T_FLOAT,Opcodes.T_DOUBLE,Opcodes.T_BYTE,Opcodes.T_SHORT,Opcodes.T_INTorOpcodes.T_LONG.
-
visitVarInsn
public void visitVarInsn(int opcode, int var)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitVarInsn(int, int).- Specified by:
visitVarInsnin classPrinter- Parameters:
opcode- the opcode of the local variable instruction to be visited. This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.var- the operand of the instruction to be visited. This operand is the index of a local variable.
-
visitTypeInsn
public void visitTypeInsn(int opcode, java.lang.String type)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitTypeInsn(int, java.lang.String). /** Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as parameter.- Specified by:
visitTypeInsnin classPrinter- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.type- the operand of the instruction to be visited. This operand must be the internal name of an object or array class (seegetInternalName).
-
visitFieldInsn
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String).- Specified by:
visitFieldInsnin classPrinter- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.owner- the internal name of the field's owner class (seegetInternalName).name- the field's name.desc- the field's descriptor (seeType).
-
visitMethodInsn
@Deprecated public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Deprecated.Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String).- Overrides:
visitMethodInsnin classPrinter- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.owner- the internal name of the method's owner class (seegetInternalName).name- the method's name.desc- the method's descriptor (seeType).
-
visitMethodInsn
public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.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- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.owner- the internal name of the method's owner class (seegetInternalName).name- the method's name.desc- the method's descriptor (seeType).itf- if the method's owner class is an interface.
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String desc, Handle bsm, java.lang.Object... bsmArgs)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitInvokeDynamicInsn(java.lang.String, java.lang.String, org.objectweb.asm.Handle, java.lang.Object...). Visits an invokedynamic instruction.- Specified by:
visitInvokeDynamicInsnin classPrinter- Parameters:
name- the method's name.desc- the method's descriptor (seeType).bsm- the bootstrap method.bsmArgs- the bootstrap method constant arguments. Each argument must be anInteger,Float,Long,Double,String,TypeorHandlevalue. This method is allowed to modify the content of the array so a caller should expect that this array may change.
-
visitJumpInsn
public void visitJumpInsn(int opcode, Label label)Description copied from class:PrinterMethod jump instruction. SeeMethodVisitor.visitJumpInsn(int, org.objectweb.asm.Label).- Specified by:
visitJumpInsnin classPrinter- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.label- the operand of the instruction to be visited. This operand is a label that designates the instruction to which the jump instruction may jump.
-
visitLabel
public void visitLabel(Label label)
Description copied from class:PrinterMethod label. SeeMethodVisitor.visitLabel(org.objectweb.asm.Label).- Specified by:
visitLabelin classPrinter- Parameters:
label- aLabelobject.
-
visitLdcInsn
public void visitLdcInsn(java.lang.Object cst)
Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitLdcInsn(java.lang.Object). Visits a LDC instruction. Note that new constant types may be added in future versions of the Java Virtual Machine. To easily detect new constant types, implementations of this method should check for unexpected constant types, like this:if (cst instanceof Integer) { // ... } else if (cst instanceof Float) { // ... } else if (cst instanceof Long) { // ... } else if (cst instanceof Double) { // ... } else if (cst instanceof String) { // ... } else if (cst instanceof Type) { int sort = ((Type) cst).getSort(); if (sort == Type.OBJECT) { // ... } else if (sort == Type.ARRAY) { // ... } else if (sort == Type.METHOD) { // ... } else { // throw an exception } } else if (cst instanceof Handle) { // ... } else { // throw an exception }- Specified by:
visitLdcInsnin classPrinter- Parameters:
cst- the constant to be loaded on the stack. This parameter must be a non nullInteger, aFloat, aLong, aDouble, aString, aTypeof OBJECT or ARRAY sort for .class constants, for classes whose version is 49.0, aTypeof METHOD sort or aHandlefor MethodType and MethodHandle constants, for classes whose version is 51.0.
-
visitIincInsn
public void visitIincInsn(int var, int increment)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitIincInsn(int, int).- Specified by:
visitIincInsnin classPrinter- Parameters:
var- index of the local variable to be incremented.increment- amount to increment the local variable by.
-
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- Parameters:
min- the minimum key value.max- the maximum key value.dflt- beginning of the default handler block.labels- beginnings of the handler blocks. labels[i] is the beginning of the handler block for the min + i key.
-
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- Parameters:
dflt- beginning of the default handler block.keys- the values of the keys.labels- beginnings of the handler blocks. labels[i] is the beginning of the handler block for the keys[i] key.
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(java.lang.String desc, int dims)Description copied from class:PrinterMethod instruction. SeeMethodVisitor.visitMultiANewArrayInsn(java.lang.String, int).- Specified by:
visitMultiANewArrayInsnin classPrinter- Parameters:
desc- an array type descriptor (seeType).dims- number of dimensions of the array to allocate.
-
visitInsnAnnotation
public ASMifier visitInsnAnnotation(int typeRef, TypePath typePath, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beINSTANCEOF,NEW,CONSTRUCTOR_REFERENCE,METHOD_REFERENCE,CAST,CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT,METHOD_INVOCATION_TYPE_ARGUMENT,CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, orMETHOD_REFERENCE_TYPE_ARGUMENT. 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:
- the printer
-
visitTryCatchBlock
public void visitTryCatchBlock(Label start, Label end, Label handler, java.lang.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- Parameters:
start- beginning of the exception handler's scope (inclusive).end- end of the exception handler's scope (exclusive).handler- beginning of the exception handler's code.type- internal name of the type of exceptions handled by the handler, or null to catch any exceptions (for "finally" blocks).
-
visitTryCatchAnnotation
public ASMifier visitTryCatchAnnotation(int typeRef, TypePath typePath, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beEXCEPTION_PARAMETER. 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:
- the printer
-
visitLocalVariable
public void visitLocalVariable(java.lang.String name, java.lang.String desc, java.lang.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- Parameters:
name- the name of a local variable.desc- the type descriptor of this local variable.signature- the type signature of this local variable. May be null if the local variable type does not use generic types.start- the first instruction corresponding to the scope of this local variable (inclusive).end- the last instruction corresponding to the scope of this local variable (exclusive).index- the local variable's index.
-
visitLocalVariableAnnotation
public Printer visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, java.lang.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- Parameters:
typeRef- a reference to the annotated type. The sort of this type reference must beLOCAL_VARIABLEorRESOURCE_VARIABLE. 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.start- the fist instructions corresponding to the continuous ranges that make the scope of this local variable (inclusive).end- the last instructions corresponding to the continuous ranges that make the scope of this local variable (exclusive). This array must have the same size as the 'start' array.index- the local variable's index in each range. This array must have the same size as the 'start' array.desc- the class descriptor of the annotation class.visible- true if the annotation is visible at runtime.- Returns:
- the printer
-
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- Parameters:
line- a line number. This number refers to the source file from which the class was compiled.start- the first instruction corresponding to this line number.
-
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 ASMifier visitAnnotation(java.lang.String desc, boolean visible)
-
visitTypeAnnotation
public ASMifier visitTypeAnnotation(int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
-
visitTypeAnnotation
public ASMifier visitTypeAnnotation(java.lang.String method, int typeRef, TypePath typePath, java.lang.String desc, boolean visible)
-
visitAttribute
public void visitAttribute(Attribute attr)
-
createASMifier
protected ASMifier createASMifier(java.lang.String name, int id)
-
appendConstant
protected void appendConstant(java.lang.Object cst)
Appends a string representation of the given constant to the given buffer.- Parameters:
cst- anInteger,Float,Long,DoubleorStringobject. May be null.
-
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.
-
-