Package com.tonic.parser
Class MethodEntry
- java.lang.Object
-
- com.tonic.parser.MemberEntry
-
- com.tonic.parser.MethodEntry
-
public class MethodEntry extends MemberEntry
A method entry of a class file, parsed from bytes or built for dynamic creation.
-
-
Constructor Summary
Constructors Constructor Description MethodEntry(ClassFile classFile)Constructs a MethodEntry by parsing from the class file.MethodEntry(ClassFile classFile, int accessFlags, int nameIndex, int descIndex, List<Attribute> attributes)Constructs a MethodEntry for dynamically creating methods.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(AbstractClassVisitor visitor)Dispatches the class visitor to this method.voidaccept(AbstractMethodVisitor visitor)Dispatches a method visitor over this method.CodeAttributegetCodeAttribute()Retrieves the CodeAttribute associated with this method.booleanisPrimitiveArrayReturn()booleanisPrimitiveReturn()booleanisReferenceArrayReturn()booleanisReferenceReturn()booleanisVoidReturn()voidsetName(String newName)StringtoString()voidwrite(DataOutputStream dos)Writes this member entry to the output stream.-
Methods inherited from class com.tonic.parser.MemberEntry
getAccess, getAttributes, getClassFile, getDesc, getDescIndex, getKey, getName, getNameIndex, getOwnerName, setAccess, setAttributes, setClassFile, setDesc, setDescIndex, setKey, setNameIndex, setOwnerName
-
-
-
-
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 instanceaccessFlags- the access flags for the methodnameIndex- the index of the method name in the constant pooldescIndex- the index of the method descriptor in the constant poolattributes- the list of attributes for the method
-
-
Method Detail
-
setName
public void setName(String newName)
- Overrides:
setNamein classMemberEntry- Parameters:
newName- the member name
-
getCodeAttribute
public CodeAttribute getCodeAttribute()
Retrieves the CodeAttribute associated with this method.- Returns:
- the CodeAttribute if present, otherwise null
-
write
public void write(DataOutputStream dos) throws IOException
Description copied from class:MemberEntryWrites this member entry to the output stream.- Specified by:
writein classMemberEntry- Parameters:
dos- the DataOutputStream to write to- Throws:
IOException- if an I/O error occurs
-
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
-
-