javassist.bytecode
public final class MethodInfo extends Object
method_info
structure.
See Also: CtMethod CtConstructor
Field Summary | |
---|---|
static String | nameClinit
The name of class initializer (static initializer):
<clinit> . |
static String | nameInit
The name of constructors: <init> . |
Constructor Summary | |
---|---|
MethodInfo(ConstPool cp, String methodname, String desc)
Constructs a method_info structure. | |
MethodInfo(ConstPool cp, String methodname, MethodInfo src, Map classnameMap)
Constructs a copy of method_info structure. |
Method Summary | |
---|---|
void | addAttribute(AttributeInfo info)
Appends an attribute. |
int | getAccessFlags()
Returns access flags.
|
AttributeInfo | getAttribute(String name)
Returns the attribute with the specified name. |
List | getAttributes()
Returns all the attributes. |
CodeAttribute | getCodeAttribute()
Returns a Code attribute.
|
ConstPool | getConstPool()
Returns a constant pool table used by this method. |
String | getDescriptor()
Returns a method descriptor.
|
ExceptionsAttribute | getExceptionsAttribute()
Returns an Exceptions attribute.
|
int | getLineNumber(int pos)
Returns the line number of the source line corresponding to the specified
bytecode contained in this method.
|
String | getName()
Returns a method name. |
boolean | isConstructor()
Returns true if this is a constructor. |
boolean | isMethod()
Returns true if this is not a constructor or a class initializer (static
initializer). |
boolean | isStaticInitializer()
Returns true if this is a class initializer (static initializer). |
void | removeCodeAttribute()
Removes a Code attribute. |
void | removeExceptionsAttribute()
Removes an Exception attribute. |
void | setAccessFlags(int acc)
Sets access flags.
|
void | setCodeAttribute(CodeAttribute cattr)
Adds a Code attribute.
|
void | setDescriptor(String desc)
Sets a method descriptor.
|
void | setExceptionsAttribute(ExceptionsAttribute cattr)
Adds an Exception attribute.
|
void | setName(String newName)
Sets a method name. |
void | setSuperclass(String superclass)
Changes a super constructor called by this constructor.
|
String | toString()
Returns a string representation of the object. |
<clinit>
.<init>
.method_info
structure. The initial value of
access_flags
is zero.
Parameters: cp a constant pool table methodname method name desc method descriptor
See Also: Descriptor
method_info
structure. Class names
appearing in the source method_info
are renamed according
to classnameMap
.
Note: only Code
and Exceptions
attributes
are copied from the source. The other attributes are ignored.
Parameters: cp
a constant pool table methodname
a method name src
a source method_info
classnameMap
specifies pairs of replaced and substituted name.
See Also: Descriptor
See Also: getAttributes
See Also: AccessFlag
Parameters: name attribute name
Returns: an AttributeInfo
object or null.
See Also: getAttributes
List
object
is shared with this object. If you add a new attribute to the list,
the attribute is also added to the method represented by this
object. If you remove an attribute from the list, it is also removed
from the method.
Returns: a list of AttributeInfo
objects.
See Also: AttributeInfo
Returns: a Code attribute or null if it is not specified.
See Also: Descriptor
Returns: an Exceptions attribute or null if it is not specified.
Parameters: pos the position of the bytecode (>= 0). an index into the code array.
Returns: -1 if this information is not available.
See Also: AccessFlag
The added attribute must share the same constant pool table as this
method_info
structure.
See Also: Descriptor
The added attribute must share the same constant pool table as this
method_info
structure.
This method modifies a call to super()
, which should be
at the head of a constructor body, so that a constructor in a different
super class is called. This method does not change actural parameters.
Hence the new super class must have a constructor with the same signature
as the original one.
This method should be called when the super class of the class declaring this method is changed.
This method does not perform anything unless this MethodInfo
represents a constructor.
Parameters: superclass the new super class