Class Method
java.lang.Object
org.apache.bcel.classfile.AccessFlags
org.apache.bcel.classfile.FieldOrMethod
org.apache.bcel.classfile.Method
This class represents the method info structure, that is, the representation for a method in the class. See JVM
specification for details. A method has access flags, a name, a signature and a number of attributes.
-
Field Summary
FieldsFields inherited from class FieldOrMethod
attributes, attributes_count, constant_pool, name_index, signature_indexModifier and TypeFieldDescriptionprotected Attribute[]Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be removed (not needed)protected ConstantPoolDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.protected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter.Fields inherited from class AccessFlags
access_flagsModifier and TypeFieldDescriptionprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.copy(ConstantPool constantPool) Creates a deep copy of this method.booleanReturn value as defined by given BCELComparator strategy.Type[]Gets an array of method argument types.getCode()Gets the Code attribute of the method, if any.static BCELComparator<Method> Gets the comparison strategy object.Gets the ExceptionTable attribute of the method, if any.Gets the LineNumberTable of the code attribute, if any.Gets the LocalVariableTable of the code attribute, if any.Gets the local variable type table attributeLocalVariableTypeTable.Gets the annotations on the parameters of a method.Gets return type of method.inthashCode()Return value as defined by given BCELComparator strategy.static voidsetComparator(BCELComparator<Method> comparator) Sets the comparison strategy object.toString()Return string representation close to declaration format, 'public static void main(String[] args) throws IOException', for example.Methods inherited from class FieldOrMethod
copy_, dump, getAnnotationEntries, getAttribute, getAttributes, getConstantPool, getGenericSignature, getName, getNameIndex, getSignature, getSignatureIndex, setAttributes, setConstantPool, setNameIndex, setSignatureIndexModifier and TypeMethodDescriptionprotected FieldOrMethodcopy_(ConstantPool constantPool) Creates a deep copy of this field.final voiddump(DataOutputStream file) Dumps object to file stream on binary format.Gets annotations on the field or method.final <T extends Attribute>
TgetAttribute(byte tag) Gets attribute for given tag.final Attribute[]Gets the collection of object attributes.final ConstantPoolGets the constant pool used by this object.final StringGets the contents of the signature attribute on this member.final StringgetName()Gets the name of object.final intGets the index in constant pool of object's name.final StringGets the string representation of object's type signature.final intGets the index in constant pool of field signature.final voidsetAttributes(Attribute[] attributes) Sets the collection of object attributes.final voidsetConstantPool(ConstantPool constantPool) Sets the constant pool to be used for this object.final voidsetNameIndex(int nameIndex) Sets the index in constant pool of object's name.final voidsetSignatureIndex(int signatureIndex) Sets the index in constant pool of field signature.Methods inherited from class AccessFlags
getAccessFlags, getModifiers, isAbstract, isAbstract, isAnnotation, isAnnotation, isEnum, isEnum, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isSynthetic, isSynthetic, isTransient, isTransient, isVarArgs, isVarArgs, isVolatile, isVolatile, setAccessFlags, setModifiersModifier and TypeMethodDescriptionfinal intGets access flags.final intGets access flags.final booleanTests whether the abstract bit is on.final voidisAbstract(boolean flag) Sets the abstract bit.final booleanTests whether the annotation bit is on.final voidisAnnotation(boolean flag) Sets the annotation bit.final booleanisEnum()Tests whether the enum bit is on.final voidisEnum(boolean flag) Sets the enum bit.final booleanisFinal()Tests whether the final bit is on.final voidisFinal(boolean flag) Sets the final bit.final booleanTests whether the interface bit is on.final voidisInterface(boolean flag) Sets the interface bit.final booleanisNative()Tests whether the native bit is on.final voidisNative(boolean flag) Sets the native bit.final booleanTests whether the private bit is on.final voidisPrivate(boolean flag) Sets the private bit.final booleanTests whether the protected bit is on.final voidisProtected(boolean flag) Sets the protected bit.final booleanisPublic()Tests whether the public bit is on.final voidisPublic(boolean flag) Sets the public bit.final booleanisStatic()Tests whether the static bit is on.final voidisStatic(boolean flag) Sets the static bit.final booleanTests whether the strict bit is on.final voidisStrictfp(boolean flag) Sets the strict bit.final booleanTests whether the synchronized bit is on.final voidisSynchronized(boolean flag) Sets the synchronized bit.final booleanTests whether the synthetic bit is on.final voidisSynthetic(boolean flag) Sets the synthetic bit.final booleanTests whether the transient bit is on.final voidisTransient(boolean flag) Sets the transient bit.final booleanTests whether the varargs bit is on.final voidisVarArgs(boolean flag) Sets the varargs bit.final booleanTests whether the volatile bit is on.final voidisVolatile(boolean flag) Sets the volatile bit.final voidsetAccessFlags(int accessFlags) Sets access flags also known as modifiers.final voidsetModifiers(int accessFlags) Sets access flags aka "modifiers".
-
Field Details
-
EMPTY_ARRAY
-
-
Constructor Details
-
Method
public Method()Empty constructor, all attributes have to be defined via 'setXXX' methods. Use at your own risk. -
Method
public Method(int accessFlags, int nameIndex, int signatureIndex, Attribute[] attributes, ConstantPool constantPool) Constructs a Method.- Parameters:
accessFlags- Access rights of method.nameIndex- Points to method name in constant pool.signatureIndex- Points to encoded signature.attributes- Collection of attributes.constantPool- Array of constants.
-
Method
-
-
Method Details
-
getComparator
Gets the comparison strategy object.- Returns:
- Comparison strategy object.
-
setComparator
Sets the comparison strategy object.- Parameters:
comparator- Comparison strategy object.
-
accept
-
copy
Creates a deep copy of this method.- Parameters:
constantPool- The constant pool.- Returns:
- deep copy of this method.
-
equals
-
getArgumentTypes
Gets an array of method argument types.- Returns:
- array of method argument types.
-
getCode
-
getExceptionTable
Gets the ExceptionTable attribute of the method, if any.- Returns:
- ExceptionTable attribute of method, if any, that is, list all exceptions the method may throw not exception handlers.
-
getLineNumberTable
Gets the LineNumberTable of the code attribute, if any.- Returns:
- LineNumberTable of code attribute if any, for example the call is forwarded to the Code attribute.
-
getLocalVariableTable
Gets the LocalVariableTable of the code attribute, if any.- Returns:
- LocalVariableTable of code attribute if any, for example the call is forwarded to the Code attribute.
-
getLocalVariableTypeTable
Gets the local variable type table attributeLocalVariableTypeTable.- Returns:
- LocalVariableTypeTable of code attribute if any, for example the call is forwarded to the Code attribute.
- Since:
- 6.10.0
-
getParameterAnnotationEntries
Gets the annotations on the parameters of a method.- Returns:
- Annotations on the parameters of a method.
- Since:
- 6.0
-
getReturnType
-
hashCode
-
toString
-