Package org.objectweb.asm.util
Class Printer
java.lang.Object
org.objectweb.asm.util.Printer
An abstract converter from visit events to text.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
The ASM API version implemented by this class.static final String[]
The names of thetag
field values forHandle
.static final String[]
The names of the Java Virtual Machine opcodes.protected final StringBuilder
The builder used to build strings in the various visit methods.The text to be printed.static final String[]
The names of theoperand
values of theMethodVisitor.visitIntInsn(int, int)
method whenopcode
isNEWARRAY
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendString
(StringBuilder stringBuilder, String string) Appends a quoted string to the given string builder.getText()
Returns the text constructed by this visitor.void
print
(PrintWriter printWriter) Prints the text constructed by this visitor.abstract void
visit
(int version, int access, String name, String signature, String superName, String[] interfaces) Class header.abstract void
Annotation value.visitAnnotableParameterCount
(int parameterCount, boolean visible) Number of method parameters that can have annotations.abstract Printer
visitAnnotation
(String name, String descriptor) Nested annotation value.abstract Printer
Method default annotation.abstract void
Annotation end.abstract Printer
visitArray
(String name) Annotation array value.abstract Printer
visitClassAnnotation
(String descriptor, boolean visible) Class annotation.abstract void
visitClassAttribute
(Attribute attribute) Class attribute.abstract void
Class end.visitClassTypeAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Class type annotation.abstract void
Method start.abstract void
Annotation enum value.void
visitExport
(String packaze, int access, String... modules) Module export.abstract Printer
visitField
(int access, String name, String descriptor, String signature, Object value) Class field.abstract Printer
visitFieldAnnotation
(String descriptor, boolean visible) Field annotation.abstract void
visitFieldAttribute
(Attribute attribute) Field attribute.abstract void
Field end.abstract void
visitFieldInsn
(int opcode, String owner, String name, String descriptor) Method instruction.visitFieldTypeAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Field type annotation.abstract void
visitFrame
(int type, int numLocal, Object[] local, int numStack, Object[] stack) Method stack frame.abstract void
visitIincInsn
(int varIndex, int increment) Method instruction.abstract void
visitInnerClass
(String name, String outerName, String innerName, int access) Class inner name.abstract void
visitInsn
(int opcode) Method instruction.visitInsnAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Instruction type annotation.abstract void
visitIntInsn
(int opcode, int operand) Method instruction.abstract void
visitInvokeDynamicInsn
(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Method instruction.abstract void
visitJumpInsn
(int opcode, Label label) Method jump instruction.abstract void
visitLabel
(Label label) Method label.abstract void
visitLdcInsn
(Object value) Method instruction.abstract void
visitLineNumber
(int line, Label start) Method debug info.abstract void
visitLocalVariable
(String name, String descriptor, String signature, Label start, Label end, int index) Method debug info.visitLocalVariableAnnotation
(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String descriptor, boolean visible) Local variable type annotation.abstract void
visitLookupSwitchInsn
(Label dflt, int[] keys, Label[] labels) Method instruction.void
visitMainClass
(String mainClass) Module main class.abstract void
visitMaxs
(int maxStack, int maxLocals) Method max stack and max locals.abstract Printer
visitMethod
(int access, String name, String descriptor, String signature, String[] exceptions) Class method.abstract Printer
visitMethodAnnotation
(String descriptor, boolean visible) Method annotation.abstract void
visitMethodAttribute
(Attribute attribute) Method attribute.abstract void
Method end.void
visitMethodInsn
(int opcode, String owner, String name, String descriptor) Deprecated.void
visitMethodInsn
(int opcode, String owner, String name, String descriptor, boolean isInterface) Method instruction.visitMethodTypeAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Method type annotation.visitModule
(String name, int access, String version) Module.void
Module end.abstract void
visitMultiANewArrayInsn
(String descriptor, int numDimensions) Method instruction.void
visitNestHost
(String nestHost) Visits the nest host class of the class.void
visitNestMember
(String nestMember) Visits a member of the nest.void
Module open.abstract void
visitOuterClass
(String owner, String name, String descriptor) Class outer class.void
visitPackage
(String packaze) Module package.void
visitParameter
(String name, int access) Method parameter.abstract Printer
visitParameterAnnotation
(int parameter, String descriptor, boolean visible) Method parameter annotation.void
visitPermittedSubclass
(String permittedSubclass) Visits a permitted subclasses.void
visitProvide
(String service, String... providers) Module provide.visitRecordComponent
(String name, String descriptor, String signature) Visits a record component of the class.visitRecordComponentAnnotation
(String descriptor, boolean visible) Visits an annotation of the record component.void
visitRecordComponentAttribute
(Attribute attribute) Visits a non standard attribute of the record component.void
Visits the end of the record component.visitRecordComponentTypeAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Visits an annotation on a type in the record component signature.void
visitRequire
(String module, int access, String version) Module require.abstract void
visitSource
(String source, String debug) Class source.abstract void
visitTableSwitchInsn
(int min, int max, Label dflt, Label... labels) Method instruction.visitTryCatchAnnotation
(int typeRef, TypePath typePath, String descriptor, boolean visible) Try catch block type annotation.abstract void
visitTryCatchBlock
(Label start, Label end, Label handler, String type) Method exception handler.abstract void
visitTypeInsn
(int opcode, String type) Method instruction.void
Module use.abstract void
visitVarInsn
(int opcode, int varIndex) Method instruction.
-
Field Details
-
OPCODES
The names of the Java Virtual Machine opcodes. -
TYPES
The names of theoperand
values of theMethodVisitor.visitIntInsn(int, int)
method whenopcode
isNEWARRAY
. -
HANDLE_TAG
The names of thetag
field values forHandle
. -
api
protected final int apiThe ASM API version implemented by this class. The value of this field must be one of theASM
x values inOpcodes
. -
stringBuilder
The builder used to build strings in the various visit methods. -
text
The text to be printed. Since the code of methods is not necessarily visited in sequential order, one method after the other, but can be interlaced (some instructions from method one, then some instructions from method two, then some instructions from method one again...), it is not possible to print the visited instructions directly to a sequential stream. A class is therefore printed in a two steps process: a string tree is constructed during the visit, and printed to a sequential stream at the end of the visit. This string tree is stored in this field, as a string list that can contain other string lists, which can themselves contain other string lists, and so on.
-
-
Constructor Details
-
Method Details
-
visit
public abstract void visit(int version, int access, String name, String signature, String superName, String[] interfaces) Class header. SeeClassVisitor.visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
.- Parameters:
version
- the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.access
- the class's access flags (seeOpcodes
). This parameter also indicates if the class is deprecated.name
- the internal name of the class (seeType.getInternalName()
).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 (seeType.getInternalName()
). For interfaces, the super class isObject
. May be null, but only for theObject
class.interfaces
- the internal names of the class's interfaces (seeType.getInternalName()
). May be null.
-
visitSource
Class source. SeeClassVisitor.visitSource(java.lang.String, java.lang.String)
.- Parameters:
source
- the name of the source file from which the class was compiled. May be null.debug
- additional debug information to compute the correspondence between source and compiled elements of the class. May be null.
-
visitModule
- Parameters:
name
- the fully qualified name (using dots) of the module.access
- the module access flags, amongACC_OPEN
,ACC_SYNTHETIC
andACC_MANDATED
.version
- the module version, or null.- Returns:
- the printer.
-
visitNestHost
Visits the nest host class of the class. A nest is a set of classes of the same package that share access to their private members. One of these classes, called the host, lists the other members of the nest, which in turn should link to the host of their nest. This method must be called only once and only if the visited class is a non-host member of a nest. A class is implicitly its own nest, so it's invalid to call this method with the visited class name as argument.- Parameters:
nestHost
- the internal name of the host class of the nest (seeType.getInternalName()
).
-
visitOuterClass
Class outer class. SeeClassVisitor.visitOuterClass(java.lang.String, java.lang.String, java.lang.String)
.- Parameters:
owner
- internal name of the enclosing class of the class (seeType.getInternalName()
).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.descriptor
- 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
Class annotation. SeeClassVisitor.visitAnnotation(java.lang.String, boolean)
.- Parameters:
descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitClassTypeAnnotation
public Printer visitClassTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Class type annotation. SeeClassVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.CLASS_TYPE_PARAMETER
,TypeReference.CLASS_TYPE_PARAMETER_BOUND
orTypeReference.CLASS_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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitClassAttribute
Class attribute. SeeClassVisitor.visitAttribute(org.objectweb.asm.Attribute)
.- Parameters:
attribute
- an attribute.
-
visitNestMember
Visits a member of the nest. A nest is a set of classes of the same package that share access to their private members. One of these classes, called the host, lists the other members of the nest, which in turn should link to the host of their nest. This method must be called only if the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so it's invalid to call this method with the visited class name as argument.- Parameters:
nestMember
- the internal name of a nest member (seeType.getInternalName()
).
-
visitPermittedSubclass
Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the current class. SeeClassVisitor.visitPermittedSubclass(String)
.- Parameters:
permittedSubclass
- the internal name of a permitted subclass (seeType.getInternalName()
).
-
visitInnerClass
Class inner name. SeeClassVisitor.visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int)
.- Parameters:
name
- the internal name of an inner class (seeType.getInternalName()
).outerName
- the internal name of the class to which the inner class belongs (seeType.getInternalName()
). 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.
-
visitRecordComponent
Visits a record component of the class. SeeClassVisitor.visitRecordComponent(String, String, String)
.- Parameters:
name
- the field's name.descriptor
- the record component descriptor (seeType
).signature
- the record component signature. May be null if the record component type does not use generic types.- Returns:
- a visitor to visit this record component annotations and attributes, or null if this class visitor is not interested in visiting these annotations and attributes.
-
visitField
public abstract Printer visitField(int access, String name, String descriptor, String signature, Object value) Class field. SeeClassVisitor.visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
.- 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.descriptor
- 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
, aDouble
or aString
(forint
,float
,long
orString
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 abstract Printer visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) Class method. SeeClassVisitor.visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
.- 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.descriptor
- 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 (seeType.getInternalName()
). May be null.- Returns:
- the printer.
-
visitClassEnd
public abstract void visitClassEnd()Class end. SeeClassVisitor.visitEnd()
. -
visitMainClass
Module main class. SeeModuleVisitor.visitMainClass(java.lang.String)
.- Parameters:
mainClass
- the internal name of the main class of the current module (seeType.getInternalName()
).
-
visitPackage
Module package. SeeModuleVisitor.visitPackage(java.lang.String)
.- Parameters:
packaze
- the internal name of a package (seeType.getInternalName()
).
-
visitRequire
Module require. SeeModuleVisitor.visitRequire(java.lang.String, int, java.lang.String)
.- Parameters:
module
- the fully qualified name (using dots) of the dependence.access
- the access flag of the dependence amongACC_TRANSITIVE
,ACC_STATIC_PHASE
,ACC_SYNTHETIC
andACC_MANDATED
.version
- the module version at compile time, or null.
-
visitExport
Module export. SeeModuleVisitor.visitExport(java.lang.String, int, java.lang.String...)
.- Parameters:
packaze
- the internal name of the exported package (seeType.getInternalName()
).access
- the access flag of the exported package, valid values are amongACC_SYNTHETIC
andACC_MANDATED
.modules
- the fully qualified names (using dots) of the modules that can access the public classes of the exported package, or null.
-
visitOpen
Module open. SeeModuleVisitor.visitOpen(java.lang.String, int, java.lang.String...)
.- Parameters:
packaze
- the internal name of the opened package (seeType.getInternalName()
).access
- the access flag of the opened package, valid values are amongACC_SYNTHETIC
andACC_MANDATED
.modules
- the fully qualified names (using dots) of the modules that can use deep reflection to the classes of the open package, or null.
-
visitUse
Module use. SeeModuleVisitor.visitUse(java.lang.String)
.- Parameters:
service
- the internal name of the service (seeType.getInternalName()
).
-
visitProvide
Module provide. SeeModuleVisitor.visitProvide(java.lang.String, java.lang.String...)
.- Parameters:
service
- the internal name of the service (seeType.getInternalName()
).providers
- the internal names of the implementations of the service (there is at least one provider).
-
visitModuleEnd
public void visitModuleEnd()Module end. SeeModuleVisitor.visitEnd()
. -
visit
Annotation value. SeeAnnotationVisitor.visit(java.lang.String, java.lang.Object)
.- Parameters:
name
- the value name.value
- the actual value, whose type must beByte
,Boolean
,Character
,Short
,Integer
,Long
,Float
,Double
,String
orType
ofType.OBJECT
orType.ARRAY
sort. This value can also be an array of byte, boolean, short, char, int, long, float or double values (this is equivalent to usingvisitArray(java.lang.String)
and visiting each array element in turn, but is more convenient).
-
visitEnum
Annotation enum value. SeeAnnotationVisitor.visitEnum(java.lang.String, java.lang.String, java.lang.String)
.- Parameters:
name
- the value name.descriptor
- the class descriptor of the enumeration class.value
- the actual enumeration value.
-
visitAnnotation
Nested annotation value. SeeAnnotationVisitor.visitAnnotation(java.lang.String, java.lang.String)
.- Parameters:
name
- the value name.descriptor
- the class descriptor of the nested annotation class.- Returns:
- the printer.
-
visitArray
Annotation array value. SeeAnnotationVisitor.visitArray(java.lang.String)
.- Parameters:
name
- the value name.- Returns:
- the printer.
-
visitAnnotationEnd
public abstract void visitAnnotationEnd()Annotation end. SeeAnnotationVisitor.visitEnd()
. -
visitRecordComponentAnnotation
Visits an annotation of the record component. SeeRecordComponentVisitor.visitAnnotation(java.lang.String, boolean)
.- Parameters:
descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.
-
visitRecordComponentTypeAnnotation
public Printer visitRecordComponentTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Visits an annotation on a type in the record component signature. SeeRecordComponentVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.CLASS_TYPE_PARAMETER
,TypeReference.CLASS_TYPE_PARAMETER_BOUND
orTypeReference.CLASS_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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.
-
visitRecordComponentAttribute
Visits a non standard attribute of the record component. SeeRecordComponentVisitor.visitAttribute(org.objectweb.asm.Attribute)
.- Parameters:
attribute
- an attribute.
-
visitRecordComponentEnd
public void visitRecordComponentEnd()Visits the end of the record component. SeeRecordComponentVisitor.visitEnd()
. This method, which is the last one to be called, is used to inform the visitor that everything have been visited. -
visitFieldAnnotation
Field annotation. SeeFieldVisitor.visitAnnotation(java.lang.String, boolean)
.- Parameters:
descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitFieldTypeAnnotation
public Printer visitFieldTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Field type annotation. SeeFieldVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.FIELD
. 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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitFieldAttribute
Field attribute. SeeFieldVisitor.visitAttribute(org.objectweb.asm.Attribute)
.- Parameters:
attribute
- an attribute.
-
visitFieldEnd
public abstract void visitFieldEnd()Field end. SeeFieldVisitor.visitEnd()
. -
visitParameter
Method parameter. SeeMethodVisitor.visitParameter(String, int)
.- Parameters:
name
- parameter name or null if none is provided.access
- the parameter's access flags, onlyACC_FINAL
,ACC_SYNTHETIC
or/andACC_MANDATED
are allowed (seeOpcodes
).
-
visitAnnotationDefault
Method default annotation. SeeMethodVisitor.visitAnnotationDefault()
.- Returns:
- the printer.
-
visitMethodAnnotation
Method annotation. SeeMethodVisitor.visitAnnotation(java.lang.String, boolean)
.- Parameters:
descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitMethodTypeAnnotation
public Printer visitMethodTypeAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Method type annotation. SeeMethodVisitor.visitTypeAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.METHOD_TYPE_PARAMETER
,TypeReference.METHOD_TYPE_PARAMETER_BOUND
,TypeReference.METHOD_RETURN
,TypeReference.METHOD_RECEIVER
,TypeReference.METHOD_FORMAL_PARAMETER
orTypeReference.THROWS
. 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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitAnnotableParameterCount
Number of method parameters that can have annotations. SeeMethodVisitor.visitAnnotableParameterCount(int, boolean)
.- Parameters:
parameterCount
- the number of method parameters than can have annotations. This number must be less or equal than the number of parameter types in the method descriptor. It can be strictly less when a method has synthetic parameters and when these parameters are ignored when computing parameter indices for the purpose of parameter annotations (see https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18).visible
- true to define the number of method parameters that can have annotations visible at runtime, false to define the number of method parameters that can have annotations invisible at runtime.- Returns:
- the printer.
-
visitParameterAnnotation
Method parameter annotation. SeeMethodVisitor.visitParameterAnnotation(int, java.lang.String, boolean)
.- Parameters:
parameter
- the parameter index. This index must be strictly smaller than the number of parameters in the method descriptor, and strictly smaller than the parameter count specified invisitAnnotableParameterCount(int, boolean)
. Important note: a parameter index i is not required to correspond to the i'th parameter descriptor in the method descriptor, in particular in case of synthetic parameters (see https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.18).descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitMethodAttribute
Method attribute. SeeMethodVisitor.visitAttribute(org.objectweb.asm.Attribute)
.- Parameters:
attribute
- an attribute.
-
visitCode
public abstract void visitCode()Method start. SeeMethodVisitor.visitCode()
. -
visitFrame
public abstract void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) Method stack frame. SeeMethodVisitor.visitFrame(int, int, java.lang.Object[], int, java.lang.Object[])
.- Parameters:
type
- the type of this stack map frame. Must beOpcodes.F_NEW
for expanded frames, orOpcodes.F_FULL
,Opcodes.F_APPEND
,Opcodes.F_CHOP
,Opcodes.F_SAME
orOpcodes.F_APPEND
,Opcodes.F_SAME1
for compressed frames.numLocal
- 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.NULL
orOpcodes.UNINITIALIZED_THIS
(long and double are represented by a single element). Reference types are represented by String objects (representing internal names, seeType.getInternalName()
), and uninitialized types by Label objects (this label designates the NEW instruction that created this uninitialized value).numStack
- 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 abstract void visitInsn(int opcode) Method instruction. SeeMethodVisitor.visitInsn(int)
- 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 abstract void visitIntInsn(int opcode, int operand) Method instruction. SeeMethodVisitor.visitIntInsn(int, int)
.- 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_INT
orOpcodes.T_LONG
.
-
visitVarInsn
public abstract void visitVarInsn(int opcode, int varIndex) Method instruction. SeeMethodVisitor.visitVarInsn(int, int)
.- 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.varIndex
- the operand of the instruction to be visited. This operand is the index of a local variable.
-
visitTypeInsn
Method instruction. SeeMethodVisitor.visitTypeInsn(int, java.lang.String)
.- 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 (seeType.getInternalName()
).
-
visitFieldInsn
Method instruction. SeeMethodVisitor.visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String)
.- 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 (seeType.getInternalName()
).name
- the field's name.descriptor
- the field's descriptor (seeType
).
-
visitMethodInsn
Deprecated.Method instruction. SeeMethodVisitor.visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
.- 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 (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).
-
visitMethodInsn
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) Method instruction. SeeMethodVisitor.visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
.- 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 (seeType.getInternalName()
).name
- the method's name.descriptor
- the method's descriptor (seeType
).isInterface
- if the method's owner class is an interface.
-
visitInvokeDynamicInsn
public abstract void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) Method instruction. SeeMethodVisitor.visitInvokeDynamicInsn(java.lang.String, java.lang.String, org.objectweb.asm.Handle, java.lang.Object...)
.- Parameters:
name
- the method's name.descriptor
- the method's descriptor (seeType
).bootstrapMethodHandle
- the bootstrap method.bootstrapMethodArguments
- the bootstrap method constant arguments. Each argument must be anInteger
,Float
,Long
,Double
,String
,Type
orHandle
value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
-
visitJumpInsn
Method jump instruction. SeeMethodVisitor.visitJumpInsn(int, org.objectweb.asm.Label)
.- 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
Method label. SeeMethodVisitor.visitLabel(org.objectweb.asm.Label)
.- Parameters:
label
- aLabel
object.
-
visitLdcInsn
Method instruction. SeeMethodVisitor.visitLdcInsn(java.lang.Object)
.- Parameters:
value
- the constant to be loaded on the stack. This parameter must be a non nullInteger
, aFloat
, aLong
, aDouble
, aString
, aType
of OBJECT or ARRAY sort for.class
constants, for classes whose version is 49, aType
of METHOD sort for MethodType, aHandle
for MethodHandle constants, for classes whose version is 51 or aConstantDynamic
for a constant dynamic for classes whose version is 55.
-
visitIincInsn
public abstract void visitIincInsn(int varIndex, int increment) Method instruction. SeeMethodVisitor.visitIincInsn(int, int)
.- Parameters:
varIndex
- index of the local variable to be incremented.increment
- amount to increment the local variable by.
-
visitTableSwitchInsn
Method instruction. SeeMethodVisitor.visitTableSwitchInsn(int, int, org.objectweb.asm.Label, org.objectweb.asm.Label...)
.- 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 themin + i
key.
-
visitLookupSwitchInsn
Method instruction. SeeMethodVisitor.visitLookupSwitchInsn(org.objectweb.asm.Label, int[], org.objectweb.asm.Label[])
.- 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 thekeys[i]
key.
-
visitMultiANewArrayInsn
Method instruction. SeeMethodVisitor.visitMultiANewArrayInsn(java.lang.String, int)
.- Parameters:
descriptor
- an array type descriptor (seeType
).numDimensions
- the number of dimensions of the array to allocate.
-
visitInsnAnnotation
public Printer visitInsnAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Instruction type annotation. SeeMethodVisitor.visitInsnAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.INSTANCEOF
,TypeReference.NEW
,TypeReference.CONSTRUCTOR_REFERENCE
,TypeReference.METHOD_REFERENCE
,TypeReference.CAST
,TypeReference.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
,TypeReference.METHOD_INVOCATION_TYPE_ARGUMENT
,TypeReference.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
, orTypeReference.METHOD_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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitTryCatchBlock
Method exception handler. SeeMethodVisitor.visitTryCatchBlock(org.objectweb.asm.Label, org.objectweb.asm.Label, org.objectweb.asm.Label, java.lang.String)
.- Parameters:
start
- the beginning of the exception handler's scope (inclusive).end
- the end of the exception handler's scope (exclusive).handler
- the beginning of the exception handler's code.type
- the internal name of the type of exceptions handled by the handler (seeType.getInternalName()
), or null to catch any exceptions (for "finally" blocks).
-
visitTryCatchAnnotation
public Printer visitTryCatchAnnotation(int typeRef, TypePath typePath, String descriptor, boolean visible) Try catch block type annotation. SeeMethodVisitor.visitTryCatchAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.EXCEPTION_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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitLocalVariable
public abstract void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) Method debug info. SeeMethodVisitor.visitLocalVariable(java.lang.String, java.lang.String, java.lang.String, org.objectweb.asm.Label, org.objectweb.asm.Label, int)
.- Parameters:
name
- the name of a local variable.descriptor
- 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, String descriptor, boolean visible) Local variable type annotation. SeeMethodVisitor.visitTryCatchAnnotation(int, org.objectweb.asm.TypePath, java.lang.String, boolean)
.- Parameters:
typeRef
- a reference to the annotated type. The sort of this type reference must beTypeReference.LOCAL_VARIABLE
orTypeReference.RESOURCE_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.descriptor
- the class descriptor of the annotation class.visible
- true if the annotation is visible at runtime.- Returns:
- the printer.
-
visitLineNumber
Method debug info. SeeMethodVisitor.visitLineNumber(int, org.objectweb.asm.Label)
.- 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 abstract void visitMaxs(int maxStack, int maxLocals) Method max stack and max locals. SeeMethodVisitor.visitMaxs(int, int)
.- Parameters:
maxStack
- maximum stack size of the method.maxLocals
- maximum number of local variables for the method.
-
visitMethodEnd
public abstract void visitMethodEnd()Method end. SeeMethodVisitor.visitEnd()
. -
getText
Returns the text constructed by this visitor.- Returns:
- the text constructed by this visitor. See
text
.
-
print
Prints the text constructed by this visitor.- Parameters:
printWriter
- the print writer to be used.
-
appendString
Appends a quoted string to the given string builder.- Parameters:
stringBuilder
- the buffer where the string must be added.string
- the string to be added.
-
visitMethodInsn(int, String, String, String, boolean)
instead.