Class MethodVisitor 
🏭 Constructors 
constructor 
new MethodVisitor(api: number, mv: null | MethodVisitor= null): MethodVisitorConstructs a new MethodVisitor.
Parameters 
- api: 
numberthe ASM API version implemented by this visitor. Must be one of ASM4 or ASM5. - mv: 
null | MethodVisitorthe method visitor to which this visitor must delegate method calls. May be null. 
Return Type 
MethodVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:84
🏷️ Properties 
api 
api: numberThe ASM API version implemented by this visitor. The value of this field must be one of ASM4 or ASM5.
Defined in: packages/asm/libs/MethodVisitor.ts:66
mv 
mv: null | MethodVisitorThe method visitor to which this visitor must delegate method calls. May be null.
Defined in: packages/asm/libs/MethodVisitor.ts:72
🔧 Methods 
visitAnnotation 
visitAnnotation(desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation of this method.
Parameters 
- desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:139
visitAnnotationDefault 
visitAnnotationDefault(): null | AnnotationVisitorVisits the default value of this annotation interface method.
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:122
visitAttribute 
visitAttribute(attr: Attribute): voidVisits a non standard attribute of this method.
Parameters 
- attr: 
Attributean attribute. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:206
visitCode 
visitCode(): voidStarts the visit of the method's code, if any (i.e. non abstract method).
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:215
visitEnd 
visitEnd(): voidVisits the end of the method. This method, which is the last one to be called, is used to inform the visitor that all the annotations and attributes of the method have been visited.
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:849
visitFieldInsn 
visitFieldInsn(opcode: number, owner: string, name: null | string, desc: null | string): voidVisits a field instruction. A field instruction is an instruction that loads or stores the value of a field of an object.
Parameters 
- opcode: 
numberthe opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. - owner: 
stringthe internal name of the field's owner class (see [Type#getInternalName() getInternalName]). - name: 
null | stringthe field's name. - desc: 
null | stringthe field's descriptor (see Type). 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:408
visitFrame 
visitFrame(type: any, nLocal: any, local: any, nStack: any, stack: any): anyVisits the current state of the local variables and operand stack elements. This method must() be called <i>just before</i> any instruction <b>i</b> 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 <i>just before</i> <b>i</b> is executed.<br> <br> () this is mandatory only for classes whose version is greater than or equal to V1_6. <br> <br> 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): <ul> <li>In expanded form, all frames must have the F_NEW type.</li> <li>In compressed form, frames are basically "deltas" from the state of the previous frame: <ul> <li>F_SAME representing frame with exactly the same locals as the previous frame and with the empty stack.</li> <li>F_SAME1 representing frame with exactly the same locals as the previous frame and with single value on the stack ( <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the type of the stack item).</li> <li>F_APPEND representing frame with current locals are the same as the locals in the previous frame, except that additional locals are defined (<code>nLocal</code> is 1, 2 or 3 and <code>local</code> elements contains values representing added types).</li> <li>F_CHOP representing 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 (<code>nLocals</code> is 1, 2 or 3).</li> <li>F_FULL representing complete frame data.</li> </ul> </li> </ul> <br> 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).
Parameters 
- type: 
anythe type of this stack map frame. Must be F_NEW for expanded frames, or F_FULL, F_APPEND, F_CHOP, F_SAME or F_APPEND, F_SAME1 for compressed frames. - nLocal: 
anythe number of local variables in the visited frame. - local: 
anythe local variable types in this frame. This array must not be modified. Primitive types are represented by TOP, INTEGER, FLOAT, LONG, DOUBLE,NULL or 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: 
anythe number of operand stack elements in the visited frame. - stack: 
anythe operand stack types in this frame. This array must not be modified. Its content has the same format as the "local" array. 
Return Type 
any
Defined in: packages/asm/libs/MethodVisitor.ts:296
visitIincInsn 
visitIincInsn(__var: number, increment: number): voidVisits an IINC instruction.
Parameters 
- __var: 
number - increment: 
numberamount to increment the local variable by. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:592
visitInsn 
visitInsn(opcode: number): voidVisits a zero operand instruction.
Parameters 
- opcode: 
numberthe 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. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:327
visitInsnAnnotation 
visitInsnAnnotation(typeRef: number, typePath: null | TypePath, desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation on an instruction. This method must be called just <i>after</i> the annotated instruction. It can be called several times for the same instruction.
Parameters 
- typeRef: 
numbera reference to the annotated type. The sort of this type reference must be [TypeReference#INSTANCEOF INSTANCEOF], [TypeReference#NEW NEW], [TypeReference#CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE], [TypeReference#METHOD_REFERENCE METHOD_REFERENCE], [TypeReference#CAST CAST], [TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT], [TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT], [TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT], or [TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT]. See TypeReference. - typePath: 
null | TypePaththe path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole. - desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:679
visitIntInsn 
visitIntInsn(opcode: number, operand: number): voidVisits an instruction with a single int operand.
Parameters 
- opcode: 
numberthe opcode of the instruction to be visited. This opcode is either BIPUSH, SIPUSH or NEWARRAY. - operand: 
numberthe operand of the instruction to be visited.<br> When opcode is BIPUSH, operand value should be between Byte.MIN_VALUE and Byte.MAX_VALUE.<br> When opcode is SIPUSH, operand value should be between Short.MIN_VALUE and Short.MAX_VALUE.<br> When opcode is NEWARRAY, operand value should be one of T_BOOLEAN, T_CHAR, T_FLOAT, T_DOUBLE, T_BYTE, T_SHORT, T_INT or T_LONG. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:351
visitInvokeDynamicInsn 
visitInvokeDynamicInsn(name: string, desc: string, bsm: Handle, bsmArgs: any[]): voidVisits an invokedynamic instruction.
Parameters 
- name: 
stringthe method's name. - desc: 
stringthe method's descriptor (see Type). - bsm: 
Handlethe bootstrap method. - bsmArgs: 
any[]the bootstrap method constant arguments. Each argument must be an [Integer], [Float], [Long], [Double], [String], Type or Handle value. This method is allowed to modify the content of the array so a caller should expect that this array may change. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:495
visitJumpInsn 
visitJumpInsn(opcode: number, label: Label): voidVisits a jump instruction. A jump instruction is an instruction that may jump to another instruction.
Parameters 
- opcode: 
numberthe 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: 
Labelthe operand of the instruction to be visited. This operand is a label that designates the instruction to which the jump instruction may jump. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:515
visitLabel 
visitLabel(label: Label): voidVisits a label. A label designates the instruction that will be visited just after it.
Parameters 
- label: 
Labela Label object. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:528
visitLdcInsn 
visitLdcInsn(cst: any): voidVisits 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:
<pre> 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 } </pre>
Parameters 
- cst: 
anythe constant to be loaded on the stack. This parameter must be a non null [Integer], a [Float], a [Long], a [Double], a [String], a Type of OBJECT or ARRAY sort for <tt>.class</tt> constants, for classes whose version is 49.0, a Type of METHOD sort or a Handle for MethodType and MethodHandle constants, for classes whose version is 51.0. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:578
visitLineNumber 
visitLineNumber(line: number, start: Label): voidVisits a line number declaration.
Parameters 
- line: 
numbera line number. This number refers to the source file from which the class was compiled. - start: 
Labelthe first instruction corresponding to this line number. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:823
visitLocalVariable 
visitLocalVariable(name: null | string, desc: null | string, signature: null | string, start: Label, end: Label, index: number): voidVisits a local variable declaration.
Parameters 
- name: 
null | stringthe name of a local variable. - desc: 
null | stringthe type descriptor of this local variable. - signature: 
null | stringthe type signature of this local variable. May be <tt>null</tt> if the local variable type does not use generic types. - start: 
Labelthe first instruction corresponding to the scope of this local variable (inclusive). - end: 
Labelthe last instruction corresponding to the scope of this local variable (exclusive). - index: 
numberthe local variable's index. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:766
visitLocalVariableAnnotation 
visitLocalVariableAnnotation(typeRef: number, typePath: null | TypePath, start: Label[], end: Label[], index: number[], desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation on a local variable type.
Parameters 
- typeRef: 
numbera reference to the annotated type. The sort of this type reference must be [TypeReference#LOCAL_VARIABLE LOCAL_VARIABLE] or [TypeReference#RESOURCE_VARIABLE RESOURCE_VARIABLE]. See TypeReference. - typePath: 
null | TypePaththe path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole. - start: 
Label[]the fist instructions corresponding to the continuous ranges that make the scope of this local variable (inclusive). - end: 
Label[]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: 
number[]the local variable's index in each range. This array must have the same size as the 'start' array. - desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:801
visitLookupSwitchInsn 
visitLookupSwitchInsn(dflt: Label, keys: number[], labels: Label[]): voidVisits a LOOKUPSWITCH instruction.
Parameters 
- dflt: 
Labelbeginning of the default handler block. - keys: 
number[]the values of the keys. - labels: 
Label[]beginnings of the handler blocks. <tt>labels[i]</tt> is the beginning of the handler block for the <tt>keys[i]</tt> key. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:628
visitMaxs 
visitMaxs(maxStack: number, maxLocals: number): voidVisits the maximum stack size and the maximum number of local variables of the method.
Parameters 
- maxStack: 
numbermaximum stack size of the method. - maxLocals: 
numbermaximum number of local variables for the method. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:838
visitMethodInsn 
visitMethodInsn(opcode: any, owner: any, name: any, desc: any, itf: any): anyVisits a method instruction. A method instruction is an instruction that invokes a method.
Parameters 
- opcode: 
anythe opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. - owner: 
anythe internal name of the method's owner class (see [Type#getInternalName() getInternalName]). - name: 
anythe method's name. - desc: 
anythe method's descriptor (see Type). - itf: 
anyif the method's owner class is an interface. 
Return Type 
any
Defined in: packages/asm/libs/MethodVisitor.ts:459
visitMethodInsn$int$java_lang_String$java_lang_String$java_lang_String 
visitMethodInsn$int$java_lang_String$java_lang_String$java_lang_String(opcode: number, owner: string, name: string, desc: string): voidVisits a method instruction. A method instruction is an instruction that invokes a method.
Parameters 
- opcode: 
numberthe opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. - owner: 
stringthe internal name of the method's owner class (see [Type#getInternalName() getInternalName]). - name: 
stringthe method's name. - desc: 
stringthe method's descriptor (see Type). 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:430
visitMultiANewArrayInsn 
visitMultiANewArrayInsn(desc: string, dims: number): voidVisits a MULTIANEWARRAY instruction.
Parameters 
- desc: 
stringan array type descriptor (see Type). - dims: 
numbernumber of dimensions of the array to allocate. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:642
visitParameter 
visitParameter(name: null | string, access: number): voidVisits a parameter of this method.
Parameters 
- name: 
null | stringparameter name or null if none is provided. - access: 
numberthe parameter's access flags, only <tt>ACC_FINAL</tt>, <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are allowed (see Opcodes). 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:103
visitParameterAnnotation 
visitParameterAnnotation(parameter: number, desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation of a parameter this method.
Parameters 
- parameter: 
numberthe parameter index. - desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:193
visitTableSwitchInsn 
visitTableSwitchInsn(min: number, max: number, dflt: Label, labels: Label[]): voidVisits a TABLESWITCH instruction.
Parameters 
- min: 
numberthe minimum key value. - max: 
numberthe maximum key value. - dflt: 
Labelbeginning of the default handler block. - labels: 
Label[]beginnings of the handler blocks. <tt>labels[i]</tt> is the beginning of the handler block for the <tt>min + i</tt> key. 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:611
visitTryCatchAnnotation 
visitTryCatchAnnotation(typeRef: number, typePath: null | TypePath, desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation on an exception handler type. This method must be called <i>after</i> the #visitTryCatchBlock for the annotated exception handler. It can be called several times for the same exception handler.
Parameters 
- typeRef: 
numbera reference to the annotated type. The sort of this type reference must be [TypeReference#EXCEPTION_PARAMETER EXCEPTION_PARAMETER]. See TypeReference. - typePath: 
null | TypePaththe path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole. - desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:733
visitTryCatchBlock 
visitTryCatchBlock(start: Label, end: Label, handler: Label, type: null | string): voidVisits a try catch block.
Parameters 
- start: 
Labelbeginning of the exception handler's scope (inclusive). - end: 
Labelend of the exception handler's scope (exclusive). - handler: 
Labelbeginning of the exception handler's code. - type: 
null | stringinternal name of the type of exceptions handled by the handler, or <tt>null</tt> to catch any exceptions (for "finally" blocks). 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:706
visitTypeAnnotation 
visitTypeAnnotation(typeRef: number, typePath: null | TypePath, desc: null | string, visible: boolean): null | AnnotationVisitorVisits an annotation on a type in the method signature.
Parameters 
- typeRef: 
numbera reference to the annotated type. The sort of this type reference must be [TypeReference#METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER], [TypeReference#METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND], [TypeReference#METHOD_RETURN METHOD_RETURN], [TypeReference#METHOD_RECEIVER METHOD_RECEIVER], [TypeReference#METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER] or [TypeReference#THROWS THROWS]. See TypeReference. - typePath: 
null | TypePaththe path to the annotated type argument, wildcard bound, array element type, or static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole. - desc: 
null | stringthe class descriptor of the annotation class. - visible: 
boolean<tt>true</tt> if the annotation is visible at runtime. 
Return Type 
null | AnnotationVisitor
Defined in: packages/asm/libs/MethodVisitor.ts:171
visitTypeInsn 
visitTypeInsn(opcode: number, type: string): voidVisits a type instruction. A type instruction is an instruction that takes the internal name of a class as parameter.
Parameters 
- opcode: 
numberthe opcode of the type instruction to be visited. This opcode is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF. - type: 
stringthe operand of the instruction to be visited. This operand must be the internal name of an object or array class (see [Type#getInternalName() getInternalName]). 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:387
visitVarInsn 
visitVarInsn(opcode: number, __var: number): voidVisits a local variable instruction. A local variable instruction is an instruction that loads or stores the value of a local variable.
Parameters 
- opcode: 
numberthe 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: 
number 
Return Type 
void
Defined in: packages/asm/libs/MethodVisitor.ts:369