|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavassist.bytecode.MethodInfo
public final class MethodInfo
method_info structure.
CtBehavior.getMethodInfo(),
CtBehavior.getMethodInfo()| Field Summary | |
|---|---|
static java.lang.String |
nameClinit
The name of class initializer (static initializer): <clinit>. |
static java.lang.String |
nameInit
The name of constructors: <init>. |
| Constructor Summary | |
|---|---|
MethodInfo(ConstPool cp,
java.lang.String methodname,
MethodInfo src,
java.util.Map classnameMap)
Constructs a copy of method_info structure. |
|
MethodInfo(ConstPool cp,
java.lang.String methodname,
java.lang.String desc)
Constructs a method_info structure. |
|
| Method Summary | |
|---|---|
void |
addAttribute(AttributeInfo info)
Appends an attribute. |
int |
getAccessFlags()
Returns access flags. |
AttributeInfo |
getAttribute(java.lang.String name)
Returns the attribute with the specified name. |
java.util.List |
getAttributes()
Returns all the attributes. |
CodeAttribute |
getCodeAttribute()
Returns a Code attribute. |
ConstPool |
getConstPool()
Returns a constant pool table used by this method. |
java.lang.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. |
java.lang.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 |
rebuildStackMap(ClassPool pool)
Rebuilds a stack map table. |
void |
rebuildStackMapIf6(ClassPool pool,
ClassFile cf)
Rebuilds a stack map table if the class file is for Java 6 or later. |
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(java.lang.String desc)
Sets a method descriptor. |
void |
setExceptionsAttribute(ExceptionsAttribute cattr)
Adds an Exception attribute. |
void |
setName(java.lang.String newName)
Sets a method name. |
void |
setSuperclass(java.lang.String superclass)
Changes a super constructor called by this constructor. |
java.lang.String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String nameInit
<init>.
public static final java.lang.String nameClinit
<clinit>.
| Constructor Detail |
|---|
public MethodInfo(ConstPool cp,
java.lang.String methodname,
java.lang.String desc)
method_info structure. The initial value of
access_flags is zero.
cp - a constant pool tablemethodname - method namedesc - method descriptorDescriptor
public MethodInfo(ConstPool cp,
java.lang.String methodname,
MethodInfo src,
java.util.Map classnameMap)
throws BadBytecode
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.
cp - a constant pool tablemethodname - a method namesrc - a source method_infoclassnameMap - specifies pairs of replaced and substituted name.
BadBytecodeDescriptor| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getName()
public void setName(java.lang.String newName)
public boolean isMethod()
public ConstPool getConstPool()
public boolean isConstructor()
public boolean isStaticInitializer()
public int getAccessFlags()
AccessFlagpublic void setAccessFlags(int acc)
AccessFlagpublic java.lang.String getDescriptor()
Descriptorpublic void setDescriptor(java.lang.String desc)
Descriptorpublic java.util.List 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.
AttributeInfo objects.AttributeInfopublic AttributeInfo getAttribute(java.lang.String name)
name - attribute name
AttributeInfo object or null.getAttributes()public void addAttribute(AttributeInfo info)
getAttributes()public ExceptionsAttribute getExceptionsAttribute()
public CodeAttribute getCodeAttribute()
public void removeExceptionsAttribute()
public void setExceptionsAttribute(ExceptionsAttribute cattr)
The added attribute must share the same constant pool table as this
method_info structure.
public void removeCodeAttribute()
public void setCodeAttribute(CodeAttribute cattr)
The added attribute must share the same constant pool table as this
method_info structure.
public void rebuildStackMapIf6(ClassPool pool,
ClassFile cf)
throws BadBytecode
pool - used for making type hierarchy.cf - rebuild if this class file is for Java 6 or later.
BadBytecoderebuildStackMap(ClassPool)
public void rebuildStackMap(ClassPool pool)
throws BadBytecode
MethodInfo does not
include a code attribute, nothing happens.
pool - used for making type hierarchy.
BadBytecodeStackMapTablepublic int getLineNumber(int pos)
pos - the position of the bytecode (>= 0). an index into the code
array.
public void setSuperclass(java.lang.String superclass)
throws BadBytecode
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 actual 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.
superclass - the new super class
BadBytecode
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||