Package org.objectweb.asm.tree
Class MethodNode
java.lang.Object
org.objectweb.asm.MethodVisitor
org.objectweb.asm.tree.MethodNode
public class MethodNode
extends org.objectweb.asm.MethodVisitor
A node that represents a method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionintThe method's access flags (seeOpcodes).The default value of this annotation interface method.List<org.objectweb.asm.Attribute>The non standard attributes of this method.The method's descriptor (seeType).The internal names of the method's exception classes (seeType.getInternalName()).The instructions of this method.intThe number of method parameters than can have runtime invisible annotations.The runtime invisible annotations of this method.The invisible local variable annotations of this method.The runtime invisible parameter annotations of this method.The runtime invisible type annotations of this method.The local variables of this method.intThe maximum number of local variables of this method.intThe maximum stack size of this method.The method's name.The method parameter info (access flags and name).The method's signature.The try catch blocks of this method.intThe number of method parameters than can have runtime visible annotations.The runtime visible annotations of this method.The visible local variable annotations of this method.The runtime visible parameter annotations of this method.The runtime visible type annotations of this method.Fields inherited from class org.objectweb.asm.MethodVisitor
api, mv -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an uninitializedMethodNode.MethodNode(int api) Constructs an uninitializedMethodNode.MethodNode(int api, int access, String name, String descriptor, String signature, String[] exceptions) Constructs a newMethodNode.MethodNode(int access, String name, String descriptor, String signature, String[] exceptions) Constructs a newMethodNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(org.objectweb.asm.ClassVisitor classVisitor) Makes the given class visitor visit this method.voidaccept(org.objectweb.asm.MethodVisitor methodVisitor) Makes the given method visitor visit this method.voidcheck(int api) Checks that this method node is compatible with the given ASM API version.protected LabelNodegetLabelNode(org.objectweb.asm.Label label) Returns the LabelNode corresponding to the given Label.voidvisitAnnotableParameterCount(int parameterCount, boolean visible) org.objectweb.asm.AnnotationVisitorvisitAnnotation(String descriptor, boolean visible) org.objectweb.asm.AnnotationVisitorvoidvisitAttribute(org.objectweb.asm.Attribute attribute) voidvoidvisitEnd()voidvisitFieldInsn(int opcode, String owner, String name, String descriptor) voidvisitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) voidvisitIincInsn(int varIndex, int increment) voidvisitInsn(int opcode) org.objectweb.asm.AnnotationVisitorvisitInsnAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) voidvisitIntInsn(int opcode, int operand) voidvisitInvokeDynamicInsn(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label) voidvisitLabel(org.objectweb.asm.Label label) voidvisitLdcInsn(Object value) voidvisitLineNumber(int line, org.objectweb.asm.Label start) voidvisitLocalVariable(String name, String descriptor, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index) org.objectweb.asm.AnnotationVisitorvisitLocalVariableAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] index, String descriptor, boolean visible) voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels) voidvisitMaxs(int maxStack, int maxLocals) voidvisitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface) voidvisitMultiANewArrayInsn(String descriptor, int numDimensions) voidvisitParameter(String name, int access) org.objectweb.asm.AnnotationVisitorvisitParameterAnnotation(int parameter, String descriptor, boolean visible) voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels) org.objectweb.asm.AnnotationVisitorvisitTryCatchAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) voidvisitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, String type) org.objectweb.asm.AnnotationVisitorvisitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) voidvisitTypeInsn(int opcode, String type) voidvisitVarInsn(int opcode, int varIndex) Methods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitMethodInsn
-
Field Details
-
access
public int accessThe method's access flags (seeOpcodes). This field 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. -
exceptions
The internal names of the method's exception classes (seeType.getInternalName()). -
parameters
The method parameter info (access flags and name). -
visibleAnnotations
The runtime visible annotations of this method. May be null. -
invisibleAnnotations
The runtime invisible annotations of this method. May be null. -
visibleTypeAnnotations
The runtime visible type annotations of this method. May be null. -
invisibleTypeAnnotations
The runtime invisible type annotations of this method. May be null. -
attrs
The non standard attributes of this method. May be null. -
annotationDefault
-
visibleAnnotableParameterCount
public int visibleAnnotableParameterCountThe number of method parameters than can have runtime visible annotations. This number must be less or equal than the number of parameter types in the method descriptor (the default value 0 indicates that all the parameters described in the method descriptor can have annotations). 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). -
visibleParameterAnnotations
The runtime visible parameter annotations of this method. These lists are lists ofAnnotationNodeobjects. May be null. -
invisibleAnnotableParameterCount
public int invisibleAnnotableParameterCountThe number of method parameters than can have runtime invisible annotations. This number must be less or equal than the number of parameter types in the method descriptor (the default value 0 indicates that all the parameters described in the method descriptor can have annotations). 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). -
invisibleParameterAnnotations
The runtime invisible parameter annotations of this method. These lists are lists ofAnnotationNodeobjects. May be null. -
instructions
The instructions of this method. -
tryCatchBlocks
The try catch blocks of this method. -
maxStack
public int maxStackThe maximum stack size of this method. -
maxLocals
public int maxLocalsThe maximum number of local variables of this method. -
localVariables
The local variables of this method. May be null -
visibleLocalVariableAnnotations
The visible local variable annotations of this method. May be null -
invisibleLocalVariableAnnotations
The invisible local variable annotations of this method. May be null
-
-
Constructor Details
-
MethodNode
public MethodNode()Constructs an uninitializedMethodNode. Subclasses must not use this constructor. Instead, they must use theMethodNode(int)version.- Throws:
IllegalStateException- If a subclass calls this constructor.
-
MethodNode
public MethodNode(int api) Constructs an uninitializedMethodNode.- Parameters:
api- the ASM API version implemented by this visitor. Must be one of theASMx values inOpcodes.
-
MethodNode
public MethodNode(int access, String name, String descriptor, String signature, String[] exceptions) Constructs a newMethodNode. Subclasses must not use this constructor. Instead, they must use theMethodNode(int, int, String, String, String, String[])version.- 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.exceptions- the internal names of the method's exception classes (seeType.getInternalName()). May be null.- Throws:
IllegalStateException- If a subclass calls this constructor.
-
MethodNode
public MethodNode(int api, int access, String name, String descriptor, String signature, String[] exceptions) Constructs a newMethodNode.- Parameters:
api- the ASM API version implemented by this visitor. Must be one of theASMx values inOpcodes.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.exceptions- the internal names of the method's exception classes (seeType.getInternalName()). May be null.
-
-
Method Details
-
visitParameter
- Overrides:
visitParameterin classorg.objectweb.asm.MethodVisitor
-
visitAnnotationDefault
public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()- Overrides:
visitAnnotationDefaultin classorg.objectweb.asm.MethodVisitor
-
visitAnnotation
- Overrides:
visitAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitTypeAnnotation
public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) - Overrides:
visitTypeAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitAnnotableParameterCount
public void visitAnnotableParameterCount(int parameterCount, boolean visible) - Overrides:
visitAnnotableParameterCountin classorg.objectweb.asm.MethodVisitor
-
visitParameterAnnotation
public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter, String descriptor, boolean visible) - Overrides:
visitParameterAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitAttribute
public void visitAttribute(org.objectweb.asm.Attribute attribute) - Overrides:
visitAttributein classorg.objectweb.asm.MethodVisitor
-
visitCode
public void visitCode()- Overrides:
visitCodein classorg.objectweb.asm.MethodVisitor
-
visitFrame
- Overrides:
visitFramein classorg.objectweb.asm.MethodVisitor
-
visitInsn
public void visitInsn(int opcode) - Overrides:
visitInsnin classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand) - Overrides:
visitIntInsnin classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int varIndex) - Overrides:
visitVarInsnin classorg.objectweb.asm.MethodVisitor
-
visitTypeInsn
- Overrides:
visitTypeInsnin classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
- Overrides:
visitFieldInsnin classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
public void visitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface) - Overrides:
visitMethodInsnin classorg.objectweb.asm.MethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) - Overrides:
visitInvokeDynamicInsnin classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label) - Overrides:
visitJumpInsnin classorg.objectweb.asm.MethodVisitor
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label) - Overrides:
visitLabelin classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
- Overrides:
visitLdcInsnin classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int varIndex, int increment) - Overrides:
visitIincInsnin classorg.objectweb.asm.MethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels) - Overrides:
visitTableSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels) - Overrides:
visitLookupSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitMultiANewArrayInsn
- Overrides:
visitMultiANewArrayInsnin classorg.objectweb.asm.MethodVisitor
-
visitInsnAnnotation
public org.objectweb.asm.AnnotationVisitor visitInsnAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) - Overrides:
visitInsnAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitTryCatchBlock
public void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, String type) - Overrides:
visitTryCatchBlockin classorg.objectweb.asm.MethodVisitor
-
visitTryCatchAnnotation
public org.objectweb.asm.AnnotationVisitor visitTryCatchAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, String descriptor, boolean visible) - Overrides:
visitTryCatchAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitLocalVariable
public void visitLocalVariable(String name, String descriptor, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index) - Overrides:
visitLocalVariablein classorg.objectweb.asm.MethodVisitor
-
visitLocalVariableAnnotation
public org.objectweb.asm.AnnotationVisitor visitLocalVariableAnnotation(int typeRef, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] index, String descriptor, boolean visible) - Overrides:
visitLocalVariableAnnotationin classorg.objectweb.asm.MethodVisitor
-
visitLineNumber
public void visitLineNumber(int line, org.objectweb.asm.Label start) - Overrides:
visitLineNumberin classorg.objectweb.asm.MethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals) - Overrides:
visitMaxsin classorg.objectweb.asm.MethodVisitor
-
visitEnd
public void visitEnd()- Overrides:
visitEndin classorg.objectweb.asm.MethodVisitor
-
getLabelNode
Returns the LabelNode corresponding to the given Label. Creates a new LabelNode if necessary. The default implementation of this method uses theLabel.infofield to store associations between labels and label nodes.- Parameters:
label- a Label.- Returns:
- the LabelNode corresponding to label.
-
check
public void check(int api) Checks that this method node is compatible with the given ASM API version. This method checks that this node, and all its children recursively, do not contain elements that were introduced in more recent versions of the ASM API than the given version.- Parameters:
api- an ASM API version. Must be one of theASMx values inOpcodes.
-
accept
public void accept(org.objectweb.asm.ClassVisitor classVisitor) Makes the given class visitor visit this method.- Parameters:
classVisitor- a class visitor.
-
accept
public void accept(org.objectweb.asm.MethodVisitor methodVisitor) Makes the given method visitor visit this method.- Parameters:
methodVisitor- a method visitor.
-