Class MethodNode


  • public class MethodNode
    extends org.objectweb.asm.MethodVisitor
    A node that represents a method.
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodNode()
      Constructs an uninitialized MethodNode.
      MethodNode​(int api)
      Constructs an uninitialized MethodNode.
      MethodNode​(int api, int access, java.lang.String name, java.lang.String descriptor, java.lang.String signature, java.lang.String[] exceptions)
      Constructs a new MethodNode.
      MethodNode​(int access, java.lang.String name, java.lang.String descriptor, java.lang.String signature, java.lang.String[] exceptions)
      Constructs a new MethodNode.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(org.objectweb.asm.ClassVisitor classVisitor)
      Makes the given class visitor visit this method.
      void accept​(org.objectweb.asm.MethodVisitor methodVisitor)
      Makes the given method visitor visit this method.
      void check​(int api)
      Checks that this method node is compatible with the given ASM API version.
      protected LabelNode getLabelNode​(org.objectweb.asm.Label label)
      Returns the LabelNode corresponding to the given Label.
      void visitAnnotableParameterCount​(int parameterCount, boolean visible)  
      org.objectweb.asm.AnnotationVisitor visitAnnotation​(java.lang.String descriptor, boolean visible)  
      org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()  
      void visitAttribute​(org.objectweb.asm.Attribute attribute)  
      void visitCode()  
      void visitEnd()  
      void visitFieldInsn​(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)  
      void visitFrame​(int type, int numLocal, java.lang.Object[] local, int numStack, java.lang.Object[] stack)  
      void visitIincInsn​(int var, int increment)  
      void visitInsn​(int opcode)  
      org.objectweb.asm.AnnotationVisitor visitInsnAnnotation​(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)  
      void visitIntInsn​(int opcode, int operand)  
      void visitInvokeDynamicInsn​(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)  
      void visitJumpInsn​(int opcode, org.objectweb.asm.Label label)  
      void visitLabel​(org.objectweb.asm.Label label)  
      void visitLdcInsn​(java.lang.Object value)  
      void visitLineNumber​(int line, org.objectweb.asm.Label start)  
      void visitLocalVariable​(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)  
      org.objectweb.asm.AnnotationVisitor visitLocalVariableAnnotation​(int typeRef, org.objectweb.asm.TypePath typePath, org.objectweb.asm.Label[] start, org.objectweb.asm.Label[] end, int[] index, java.lang.String descriptor, boolean visible)  
      void visitLookupSwitchInsn​(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)  
      void visitMaxs​(int maxStack, int maxLocals)  
      void visitMethodInsn​(int opcodeAndSource, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)  
      void visitMultiANewArrayInsn​(java.lang.String descriptor, int numDimensions)  
      void visitParameter​(java.lang.String name, int access)  
      org.objectweb.asm.AnnotationVisitor visitParameterAnnotation​(int parameter, java.lang.String descriptor, boolean visible)  
      void visitTableSwitchInsn​(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)  
      org.objectweb.asm.AnnotationVisitor visitTryCatchAnnotation​(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)  
      void visitTryCatchBlock​(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)  
      org.objectweb.asm.AnnotationVisitor visitTypeAnnotation​(int typeRef, org.objectweb.asm.TypePath typePath, java.lang.String descriptor, boolean visible)  
      void visitTypeInsn​(int opcode, java.lang.String type)  
      void visitVarInsn​(int opcode, int var)  
      • Methods inherited from class org.objectweb.asm.MethodVisitor

        visitMethodInsn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • access

        public int access
        The method's access flags (see Opcodes). This field also indicates if the method is synthetic and/or deprecated.
      • name

        public java.lang.String name
        The method's name.
      • desc

        public java.lang.String desc
        The method's descriptor (see Type).
      • signature

        public java.lang.String signature
        The method's signature. May be null.
      • exceptions

        public java.util.List<java.lang.String> exceptions
        The internal names of the method's exception classes (see Type.getInternalName()).
      • parameters

        public java.util.List<ParameterNode> parameters
        The method parameter info (access flags and name).
      • visibleAnnotations

        public java.util.List<AnnotationNode> visibleAnnotations
        The runtime visible annotations of this method. May be null.
      • invisibleAnnotations

        public java.util.List<AnnotationNode> invisibleAnnotations
        The runtime invisible annotations of this method. May be null.
      • visibleTypeAnnotations

        public java.util.List<TypeAnnotationNode> visibleTypeAnnotations
        The runtime visible type annotations of this method. May be null.
      • invisibleTypeAnnotations

        public java.util.List<TypeAnnotationNode> invisibleTypeAnnotations
        The runtime invisible type annotations of this method. May be null.
      • attrs

        public java.util.List<org.objectweb.asm.Attribute> attrs
        The non standard attributes of this method. May be null.
      • annotationDefault

        public java.lang.Object annotationDefault
        The default value of this annotation interface method. This field must be a Byte, Boolean, Character, Short, Integer, Long, Float, Double, String or Type, or an two elements String array (for enumeration values), a AnnotationNode, or a List of values of one of the preceding types. May be null.
      • visibleAnnotableParameterCount

        public int visibleAnnotableParameterCount
        The 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

        public java.util.List<AnnotationNode>[] visibleParameterAnnotations
        The runtime visible parameter annotations of this method. These lists are lists of AnnotationNode objects. May be null.
      • invisibleAnnotableParameterCount

        public int invisibleAnnotableParameterCount
        The 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

        public java.util.List<AnnotationNode>[] invisibleParameterAnnotations
        The runtime invisible parameter annotations of this method. These lists are lists of AnnotationNode objects. May be null.
      • instructions

        public InsnList instructions
        The instructions of this method.
      • tryCatchBlocks

        public java.util.List<TryCatchBlockNode> tryCatchBlocks
        The try catch blocks of this method.
      • maxStack

        public int maxStack
        The maximum stack size of this method.
      • maxLocals

        public int maxLocals
        The maximum number of local variables of this method.
      • localVariables

        public java.util.List<LocalVariableNode> localVariables
        The local variables of this method. May be null
      • visibleLocalVariableAnnotations

        public java.util.List<LocalVariableAnnotationNode> visibleLocalVariableAnnotations
        The visible local variable annotations of this method. May be null
      • invisibleLocalVariableAnnotations

        public java.util.List<LocalVariableAnnotationNode> invisibleLocalVariableAnnotations
        The invisible local variable annotations of this method. May be null
    • Constructor Detail

      • MethodNode

        public MethodNode()
        Constructs an uninitialized MethodNode. Subclasses must not use this constructor. Instead, they must use the MethodNode(int) version.
        Throws:
        java.lang.IllegalStateException - If a subclass calls this constructor.
      • MethodNode

        public MethodNode​(int api)
        Constructs an uninitialized MethodNode.
        Parameters:
        api - the ASM API version implemented by this visitor. Must be one of Opcodes.ASM4, Opcodes.ASM5, Opcodes.ASM6, Opcodes.ASM7, Opcodes.ASM8 or Opcodes.ASM9.
      • MethodNode

        public MethodNode​(int access,
                          java.lang.String name,
                          java.lang.String descriptor,
                          java.lang.String signature,
                          java.lang.String[] exceptions)
        Constructs a new MethodNode. Subclasses must not use this constructor. Instead, they must use the MethodNode(int, int, String, String, String, String[]) version.
        Parameters:
        access - the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
        name - the method's name.
        descriptor - the method's descriptor (see Type).
        signature - the method's signature. May be null.
        exceptions - the internal names of the method's exception classes (see Type.getInternalName()). May be null.
        Throws:
        java.lang.IllegalStateException - If a subclass calls this constructor.
      • MethodNode

        public MethodNode​(int api,
                          int access,
                          java.lang.String name,
                          java.lang.String descriptor,
                          java.lang.String signature,
                          java.lang.String[] exceptions)
        Constructs a new MethodNode.
        Parameters:
        api - the ASM API version implemented by this visitor. Must be one of Opcodes.ASM4, Opcodes.ASM5, Opcodes.ASM6, Opcodes.ASM7, Opcodes.ASM8 or Opcodes.ASM9.
        access - the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
        name - the method's name.
        descriptor - the method's descriptor (see Type).
        signature - the method's signature. May be null.
        exceptions - the internal names of the method's exception classes (see Type.getInternalName()). May be null.
    • Method Detail

      • visitParameter

        public void visitParameter​(java.lang.String name,
                                   int access)
        Overrides:
        visitParameter in class org.objectweb.asm.MethodVisitor
      • visitAnnotationDefault

        public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
        Overrides:
        visitAnnotationDefault in class org.objectweb.asm.MethodVisitor
      • visitAnnotation

        public org.objectweb.asm.AnnotationVisitor visitAnnotation​(java.lang.String descriptor,
                                                                   boolean visible)
        Overrides:
        visitAnnotation in class org.objectweb.asm.MethodVisitor
      • visitTypeAnnotation

        public org.objectweb.asm.AnnotationVisitor visitTypeAnnotation​(int typeRef,
                                                                       org.objectweb.asm.TypePath typePath,
                                                                       java.lang.String descriptor,
                                                                       boolean visible)
        Overrides:
        visitTypeAnnotation in class org.objectweb.asm.MethodVisitor
      • visitAnnotableParameterCount

        public void visitAnnotableParameterCount​(int parameterCount,
                                                 boolean visible)
        Overrides:
        visitAnnotableParameterCount in class org.objectweb.asm.MethodVisitor
      • visitParameterAnnotation

        public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation​(int parameter,
                                                                            java.lang.String descriptor,
                                                                            boolean visible)
        Overrides:
        visitParameterAnnotation in class org.objectweb.asm.MethodVisitor
      • visitAttribute

        public void visitAttribute​(org.objectweb.asm.Attribute attribute)
        Overrides:
        visitAttribute in class org.objectweb.asm.MethodVisitor
      • visitCode

        public void visitCode()
        Overrides:
        visitCode in class org.objectweb.asm.MethodVisitor
      • visitFrame

        public void visitFrame​(int type,
                               int numLocal,
                               java.lang.Object[] local,
                               int numStack,
                               java.lang.Object[] stack)
        Overrides:
        visitFrame in class org.objectweb.asm.MethodVisitor
      • visitInsn

        public void visitInsn​(int opcode)
        Overrides:
        visitInsn in class org.objectweb.asm.MethodVisitor
      • visitIntInsn

        public void visitIntInsn​(int opcode,
                                 int operand)
        Overrides:
        visitIntInsn in class org.objectweb.asm.MethodVisitor
      • visitVarInsn

        public void visitVarInsn​(int opcode,
                                 int var)
        Overrides:
        visitVarInsn in class org.objectweb.asm.MethodVisitor
      • visitTypeInsn

        public void visitTypeInsn​(int opcode,
                                  java.lang.String type)
        Overrides:
        visitTypeInsn in class org.objectweb.asm.MethodVisitor
      • visitFieldInsn

        public void visitFieldInsn​(int opcode,
                                   java.lang.String owner,
                                   java.lang.String name,
                                   java.lang.String descriptor)
        Overrides:
        visitFieldInsn in class org.objectweb.asm.MethodVisitor
      • visitMethodInsn

        public void visitMethodInsn​(int opcodeAndSource,
                                    java.lang.String owner,
                                    java.lang.String name,
                                    java.lang.String descriptor,
                                    boolean isInterface)
        Overrides:
        visitMethodInsn in class org.objectweb.asm.MethodVisitor
      • visitInvokeDynamicInsn

        public void visitInvokeDynamicInsn​(java.lang.String name,
                                           java.lang.String descriptor,
                                           org.objectweb.asm.Handle bootstrapMethodHandle,
                                           java.lang.Object... bootstrapMethodArguments)
        Overrides:
        visitInvokeDynamicInsn in class org.objectweb.asm.MethodVisitor
      • visitJumpInsn

        public void visitJumpInsn​(int opcode,
                                  org.objectweb.asm.Label label)
        Overrides:
        visitJumpInsn in class org.objectweb.asm.MethodVisitor
      • visitLabel

        public void visitLabel​(org.objectweb.asm.Label label)
        Overrides:
        visitLabel in class org.objectweb.asm.MethodVisitor
      • visitLdcInsn

        public void visitLdcInsn​(java.lang.Object value)
        Overrides:
        visitLdcInsn in class org.objectweb.asm.MethodVisitor
      • visitIincInsn

        public void visitIincInsn​(int var,
                                  int increment)
        Overrides:
        visitIincInsn in class org.objectweb.asm.MethodVisitor
      • visitTableSwitchInsn

        public void visitTableSwitchInsn​(int min,
                                         int max,
                                         org.objectweb.asm.Label dflt,
                                         org.objectweb.asm.Label... labels)
        Overrides:
        visitTableSwitchInsn in class org.objectweb.asm.MethodVisitor
      • visitLookupSwitchInsn

        public void visitLookupSwitchInsn​(org.objectweb.asm.Label dflt,
                                          int[] keys,
                                          org.objectweb.asm.Label[] labels)
        Overrides:
        visitLookupSwitchInsn in class org.objectweb.asm.MethodVisitor
      • visitMultiANewArrayInsn

        public void visitMultiANewArrayInsn​(java.lang.String descriptor,
                                            int numDimensions)
        Overrides:
        visitMultiANewArrayInsn in class org.objectweb.asm.MethodVisitor
      • visitInsnAnnotation

        public org.objectweb.asm.AnnotationVisitor visitInsnAnnotation​(int typeRef,
                                                                       org.objectweb.asm.TypePath typePath,
                                                                       java.lang.String descriptor,
                                                                       boolean visible)
        Overrides:
        visitInsnAnnotation in class org.objectweb.asm.MethodVisitor
      • visitTryCatchBlock

        public void visitTryCatchBlock​(org.objectweb.asm.Label start,
                                       org.objectweb.asm.Label end,
                                       org.objectweb.asm.Label handler,
                                       java.lang.String type)
        Overrides:
        visitTryCatchBlock in class org.objectweb.asm.MethodVisitor
      • visitTryCatchAnnotation

        public org.objectweb.asm.AnnotationVisitor visitTryCatchAnnotation​(int typeRef,
                                                                           org.objectweb.asm.TypePath typePath,
                                                                           java.lang.String descriptor,
                                                                           boolean visible)
        Overrides:
        visitTryCatchAnnotation in class org.objectweb.asm.MethodVisitor
      • visitLocalVariable

        public void visitLocalVariable​(java.lang.String name,
                                       java.lang.String descriptor,
                                       java.lang.String signature,
                                       org.objectweb.asm.Label start,
                                       org.objectweb.asm.Label end,
                                       int index)
        Overrides:
        visitLocalVariable in class org.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,
                                                                                java.lang.String descriptor,
                                                                                boolean visible)
        Overrides:
        visitLocalVariableAnnotation in class org.objectweb.asm.MethodVisitor
      • visitLineNumber

        public void visitLineNumber​(int line,
                                    org.objectweb.asm.Label start)
        Overrides:
        visitLineNumber in class org.objectweb.asm.MethodVisitor
      • visitMaxs

        public void visitMaxs​(int maxStack,
                              int maxLocals)
        Overrides:
        visitMaxs in class org.objectweb.asm.MethodVisitor
      • visitEnd

        public void visitEnd()
        Overrides:
        visitEnd in class org.objectweb.asm.MethodVisitor
      • getLabelNode

        protected LabelNode getLabelNode​(org.objectweb.asm.Label label)
        Returns the LabelNode corresponding to the given Label. Creates a new LabelNode if necessary. The default implementation of this method uses the Label.info field 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 Opcodes.ASM4, Opcodes.ASM5, Opcodes.ASM6, Opcodes.ASM7, Opcodes.ASM8 or Opcodes.ASM9.
      • 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.