APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.classfile

public final Class Method

extends FieldOrMethod
Class Inheritance
Imports
java.io.DataInput, .IOException, java.util.Objects, com.sun.org.apache.bcel.internal.generic.Type, com.sun.org.apache.bcel.internal.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.

private ParameterAnnotationEntry[]
parameterAnnotationEntries

Annotations defined on the parameters of a method.

Inherited from com.sun.org.apache.bcel.internal.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 com.sun.org.apache.bcel.internal.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
copy(final ConstantPool constantPool)

Returns: deep copy of this method

public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Return value as defined by given BCELComparator strategy.

public Type[]
getArgumentTypes()

Returns: array of method argument types

public Code
getCode()

Returns: Code attribute of method, if any

public static BCELComparator<Method>
getComparator()

Returns: Comparison strategy object.

public ExceptionTable
getExceptionTable()

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

public LineNumberTable
getLineNumberTable()

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

public LocalVariableTable
getLocalVariableTable()

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

public LocalVariableTypeTable

Returns:

LocalVariableTypeTable of code attribute if any, i.e. the call is forwarded to the Code attribute.
getLocalVariableTypeTable
()

Gets the local variable type table attribute LocalVariableTypeTable.

public ParameterAnnotationEntry[]
getParameterAnnotationEntries()

Returns: Annotations on the parameters of a method

public Type
getReturnType()

Returns: return type of method

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 com.sun.org.apache.bcel.internal.classfile.FieldOrMethod:
copy_dumpgetAnnotationEntriesgetAttributegetAttributesgetConstantPoolgetGenericSignaturegetNamegetNameIndexgetSignaturegetSignatureIndexsetAttributessetConstantPoolsetNameIndexsetSignatureIndex

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
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 com.sun.org.apache.bcel.internal.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.

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 attribute.

getLocalVariableTypeTableback to summary
public LocalVariableTypeTable getLocalVariableTypeTable()

Gets the local variable type table attribute LocalVariableTypeTable.

Returns:LocalVariableTypeTable

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

Since
6.10.0
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.

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