Class MethodEntry


  • public class MethodEntry
    extends MemberEntry
    A method entry of a class file, parsed from bytes or built for dynamic creation.
    • Constructor Detail

      • MethodEntry

        public MethodEntry​(ClassFile classFile)
        Constructs a MethodEntry by parsing from the class file.
        Parameters:
        classFile - the ClassFile instance being parsed
      • MethodEntry

        public MethodEntry​(ClassFile classFile,
                           int accessFlags,
                           int nameIndex,
                           int descIndex,
                           List<Attribute> attributes)
        Constructs a MethodEntry for dynamically creating methods.
        Parameters:
        classFile - the ClassFile instance
        accessFlags - the access flags for the method
        nameIndex - the index of the method name in the constant pool
        descIndex - the index of the method descriptor in the constant pool
        attributes - the list of attributes for the method
    • Method Detail

      • setName

        public void setName​(String newName)
        Overrides:
        setName in class MemberEntry
        Parameters:
        newName - the member name
      • getCodeAttribute

        public CodeAttribute getCodeAttribute()
        Retrieves the CodeAttribute associated with this method.
        Returns:
        the CodeAttribute if present, otherwise null
      • accept

        public void accept​(AbstractClassVisitor visitor)
        Dispatches the class visitor to this method.
        Parameters:
        visitor - the visitor to apply
      • accept

        public void accept​(AbstractMethodVisitor visitor)
                    throws IOException
        Dispatches a method visitor over this method.
        Parameters:
        visitor - the visitor to apply
        Throws:
        IOException - if the visitor fails while reading the method
      • isVoidReturn

        public boolean isVoidReturn()
        Returns:
        true if the return type is void
      • isPrimitiveReturn

        public boolean isPrimitiveReturn()
        Returns:
        true if the return type is a primitive (excluding void)
      • isReferenceReturn

        public boolean isReferenceReturn()
        Returns:
        true if the return type is a non-array reference type
      • isPrimitiveArrayReturn

        public boolean isPrimitiveArrayReturn()
        Returns:
        true if the return type is a one-dimensional primitive array
      • isReferenceArrayReturn

        public boolean isReferenceArrayReturn()
        Returns:
        true if the return type is an array with a reference element type