Top Description Fields Constructors Methods
org.apache.bcel.classfile

public final Class Method

extends FieldOrMethod
Class Inheritance
Imports
java.io.DataInput, .IOException, java.util.Objects, org.apache.bcel.generic.Type, org.apache.bcel.util.BCELComparator

This class represents the method info structure, i.e., 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

Modifier and TypeField and Description
private static BCELComparator<Method>
public static final Method[]
EMPTY_ARRAY

Empty array constant.

pack-priv static final Method[]
EMPTY_METHOD_ARRAY

Empty array.

private ParameterAnnotationEntry[]
parameterAnnotationEntries

Annotations defined on the parameters of a method.

Inherited from org.apache.bcel.classfile.FieldOrMethod:
attributesattributes_countconstant_poolname_indexsignature_index

Constructor Summary

AccessConstructor and Description
public
Method()

Empty constructor, all attributes have to be defined via 'setXXX' methods.

pack-priv
Method(final DataInput
Input stream
file
,
final ConstantPool constantPool)

Constructs object from file stream.

public
Method(final int
Access rights of method
accessFlags
,
final int
Points to field name in constant pool
nameIndex
,
final int
Points to encoded signature
signatureIndex
,
final Attribute[]
Collection of attributes
attributes
,
final ConstantPool
Array of constants
constantPool
)

public
Method(final Method
Source to copy.
c
)

Initialize from another object.

Method Summary

Modifier and TypeMethod and Description
public void
accept(final Visitor
Visitor object
v
)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
public Method

Returns:

deep copy of this method
copy
(final ConstantPool constantPool)

public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy.
public Type[]

Returns:

array of method argument types
getArgumentTypes
()

public Code

Returns:

Code attribute of method, if any
getCode
()

public static BCELComparator<Method>

Returns:

Comparison strategy object.
getComparator
()

public ExceptionTable

Returns:

ExceptionTable attribute of method, if any, i.e., list all exceptions the method may throw not exception handlers!
getExceptionTable
()

public LineNumberTable

Returns:

LineNumberTable of code attribute if any, i.e. the call is forwarded to the Code atribute.
getLineNumberTable
()

public LocalVariableTable

Returns:

LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute.
getLocalVariableTable
()

public ParameterAnnotationEntry[]

Returns:

Annotations on the parameters of a method
getParameterAnnotationEntries
()

public Type

Returns:

return type of method
getReturnType
()

public int
hashCode()

Overrides java.lang.Object.hashCode.

Return value as defined by given BCELComparator strategy.
public static void
setComparator(final BCELComparator<Method>
Comparison strategy object.
comparator
)

public String

Returns:

String representation of the method.
toString
()

Overrides java.lang.Object.toString.

Return string representation close to declaration format, 'public static void main(String[] args) throws IOException', e.g.
Inherited from org.apache.bcel.classfile.FieldOrMethod:
copy_dumpgetAnnotationEntriesgetAttributesgetConstantPoolgetGenericSignaturegetNamegetNameIndexgetSignaturegetSignatureIndexsetAttributessetConstantPoolsetNameIndexsetSignatureIndex

Field Detail

bcelComparatorback to summary
private static BCELComparator<Method> bcelComparator
EMPTY_ARRAYback to summary
public static final Method[] EMPTY_ARRAY

Empty array constant.

Since
6.6.0
EMPTY_METHOD_ARRAYback to summary
pack-priv static final Method[] EMPTY_METHOD_ARRAY

Empty array.

parameterAnnotationEntriesback to summary
private ParameterAnnotationEntry[] parameterAnnotationEntries

Annotations defined on the parameters of a method.

Constructor Detail

Methodback to summary
public Method()

Empty constructor, all attributes have to be defined via 'setXXX' methods. Use at your own risk.

Methodback to summary
pack-priv Method(final DataInput file, final ConstantPool constantPool) throws IOException, ClassFormatException

Constructs object from file stream.

Parameters
file:DataInput

Input stream

Exceptions
IOException:
if an I/O error occurs.
ClassFormatException:
if a class is malformed or cannot be interpreted as a class file
Methodback to summary
public Method(final int accessFlags, final int nameIndex, final int signatureIndex, final Attribute[] attributes, final ConstantPool constantPool)
Parameters
accessFlags:int

Access rights of method

nameIndex:int

Points to field name in constant pool

signatureIndex:int

Points to encoded signature

attributes:Attribute[]

Collection of attributes

constantPool:ConstantPool

Array of constants

Methodback to summary
public Method(final Method c)

Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

Parameters
c:Method

Source to copy.

Method Detail

acceptback to summary
public void accept(final Visitor v)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters
v:Visitor

Visitor object

Annotations
@Override
copyback to summary
public Method copy(final ConstantPool constantPool)
Returns:Method

deep copy of this method

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy. By default two method objects are said to be equal when their names and signatures are equal.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
See Also
Object#equals(Object)
getArgumentTypesback to summary
public Type[] getArgumentTypes()
Returns:Type[]

array of method argument types

getCodeback to summary
public Code getCode()
Returns:Code

Code attribute of method, if any

getComparatorback to summary
public static BCELComparator<Method> getComparator()
Returns:BCELComparator<Method>

Comparison strategy object.

getExceptionTableback to summary
public ExceptionTable getExceptionTable()
Returns:ExceptionTable

ExceptionTable attribute of method, if any, i.e., list all exceptions the method may throw not exception handlers!

getLineNumberTableback to summary
public LineNumberTable getLineNumberTable()
Returns:LineNumberTable

LineNumberTable of code attribute if any, i.e. the call is forwarded to the Code atribute.

getLocalVariableTableback to summary
public LocalVariableTable getLocalVariableTable()
Returns:LocalVariableTable

LocalVariableTable of code attribute if any, i.e. the call is forwarded to the Code atribute.

getParameterAnnotationEntriesback to summary
public ParameterAnnotationEntry[] getParameterAnnotationEntries()
Returns:ParameterAnnotationEntry[]

Annotations on the parameters of a method

Since
6.0
getReturnTypeback to summary
public Type getReturnType()
Returns:Type

return type of method

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return value as defined by given BCELComparator strategy. By default return the hash code of the method's name XOR signature.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
See Also
Object#hashCode()
setComparatorback to summary
public static void setComparator(final BCELComparator<Method> comparator)
Parameters
comparator:BCELComparator<Method>

Comparison strategy object.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return string representation close to declaration format, 'public static void main(String[] args) throws IOException', e.g.

Returns:String

String representation of the method.

Annotations
@Override