CtMethod represents a method.
See the super class CtBehavior since
a number of useful methods are in CtBehavior.
A number of useful factory methods are in CtNewMethod.
CtClass#getDeclaredMethods(), CtNewMethod
| Modifier and Type | Class and Description |
|---|---|
| public static class | CtMethod.
Instances of this class represent a constant parameter. |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| protected String |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether |
| public String | getLongName()
Implements abstract javassist. Returns the method name followed by parameter types
such as |
| public String | |
| public CtClass | |
| pack-priv final String | |
| public int | |
| public boolean | isEmpty()
Implements abstract javassist. Returns true if the method body is empty, that is, |
| public static CtMethod | |
| public static CtMethod | make(MethodInfo minfo, CtClass
the class declaring the method. declaring)Creates a method from a |
| pack-priv void | nameReplaced()
Overrides javassist. This method is invoked when setName() or replaceClassName() in CtClass is called. |
| public void | |
| public void | |
| public void | setWrappedBody(CtMethod
the wrapped method mbody, CtMethod.the constant parameter given to
the wrapped method
(maybe constParamnull).Replace a method body with a new method body wrapping the given method. |
| cachedStringRep | back to summary |
|---|---|
| protected String cachedStringRep | |
| CtMethod | back to summary |
|---|---|
| pack-priv CtMethod(MethodInfo minfo, CtClass declaring) | |
| CtMethod | back to summary |
|---|---|
| public CtMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass declaring) Creates a public abstract method. The created method must be
added to a class with
| |
| CtMethod | back to summary |
|---|---|
| public CtMethod(CtMethod src, CtClass declaring, ClassMap map) throws CannotCompileException Creates a copy of a All occurrences of class names in the created method
are replaced with names specified by
For example, suppose that a method
public X at(int i) {
return (X)super.elementAt(i);
}
(
public String at(int i) {
return (String)super.elementAt(i);
}
By default, all the occurrences of the names of the class
declaring Note if the
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Indicates whether
| |
| getLongName | back to summary |
|---|---|
| public String getLongName() Implements abstract javassist. Returns the method name followed by parameter types
such as
| |
| getName | back to summary |
|---|---|
| public String getName() Implements abstract javassist. Obtains the name of this method.
| |
| getReturnType | back to summary |
|---|---|
| public CtClass getReturnType() throws NotFoundException Obtains the type of the returned value. | |
| getStringRep | back to summary |
|---|---|
| pack-priv final String getStringRep() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code value for the method. If two methods have the same name and signature, then the hash codes for the two methods are equal.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements abstract javassist. Returns true if the method body is empty, that is,
| |
| make | back to summary |
|---|---|
| public static CtMethod make(String src, CtClass declaring) throws CannotCompileException Compiles the given source code and creates a method.
This method simply delegates to
| |
| make | back to summary |
|---|---|
| public static CtMethod make(MethodInfo minfo, CtClass declaring) throws CannotCompileException Creates a method from a
| |
| nameReplaced | back to summary |
|---|---|
| pack-priv void nameReplaced() Overrides javassist. This method is invoked when setName() or replaceClassName() in CtClass is called.
| |
| setBody | back to summary |
|---|---|
| public void setBody(CtMethod src, ClassMap map) throws CannotCompileException Copies a method body from another method. If this method is abstract, the abstract modifier is removed after the method body is copied. All occurrences of the class names in the copied method body
are replaced with the names specified by
| |
| setName | back to summary |
|---|---|
| public void setName(String newname) Changes the name of this method. | |
| setWrappedBody | back to summary |
|---|---|
| public void setWrappedBody(CtMethod mbody, CtMethod. Replace a method body with a new method body wrapping the given method.
| |
CtNewMethod.wrapped().
CtMethod#setWrappedBody(CtMethod, CtMethod.ConstParameter) , CtNewMethod#wrapped(CtClass, String, CtClass[], CtClass[], CtMethod, CtMethod.ConstParameter, CtClass) , CtNewConstructor#make(CtClass[], CtClass[], int, CtMethod, CtMethod.ConstParameter, CtClass)
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| pack-priv String | |
| pack-priv static String | |
| pack-priv static String | |
| pack-priv String | |
| public static CtMethod. | |
| public static CtMethod. | |
| public static CtMethod. |
| ConstParameter | back to summary |
|---|---|
| pack-priv ConstParameter() | |
| compile | back to summary |
|---|---|
pack-priv int compile(Bytecode code) throws CannotCompileException
| |
| constDescriptor | back to summary |
|---|---|
| pack-priv String constDescriptor() Returns the descriptor for constructors.
| |
| defaultConstDescriptor | back to summary |
|---|---|
| pack-priv static String defaultConstDescriptor() Returns the default descriptor for constructors. | |
| defaultDescriptor | back to summary |
|---|---|
pack-priv static String defaultDescriptor()
| |
| descriptor | back to summary |
|---|---|
| pack-priv String descriptor() | |
| integer | back to summary |
|---|---|
| public static CtMethod. Makes an integer constant.
| |
| integer | back to summary |
|---|---|
| public static CtMethod. Makes a long integer constant.
| |
| string | back to summary |
|---|---|
| public static CtMethod. Makes an
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| pack-priv String | constDescriptor()
Overrides javassist. Returns the descriptor for constructors. |
| pack-priv String |
| param | back to summary |
|---|---|
| pack-priv int param | |
| IntConstParameter | back to summary |
|---|---|
| pack-priv IntConstParameter(int i) | |
| compile | back to summary |
|---|---|
| pack-priv int compile(Bytecode code) throws CannotCompileException Overrides javassist.
| |
| constDescriptor | back to summary |
|---|---|
| pack-priv String constDescriptor() Overrides javassist. Doc from javassist. Returns the descriptor for constructors.
| |
| descriptor | back to summary |
|---|---|
| pack-priv String descriptor() Overrides javassist.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| pack-priv String | constDescriptor()
Overrides javassist. Returns the descriptor for constructors. |
| pack-priv String |
| param | back to summary |
|---|---|
| pack-priv long param | |
| LongConstParameter | back to summary |
|---|---|
| pack-priv LongConstParameter(long l) | |
| compile | back to summary |
|---|---|
| pack-priv int compile(Bytecode code) throws CannotCompileException Overrides javassist.
| |
| constDescriptor | back to summary |
|---|---|
| pack-priv String constDescriptor() Overrides javassist. Doc from javassist. Returns the descriptor for constructors.
| |
| descriptor | back to summary |
|---|---|
| pack-priv String descriptor() Overrides javassist.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| pack-priv String | constDescriptor()
Overrides javassist. Returns the descriptor for constructors. |
| pack-priv String |
| param | back to summary |
|---|---|
| pack-priv String param | |
| StringConstParameter | back to summary |
|---|---|
| pack-priv StringConstParameter(String s) | |
| compile | back to summary |
|---|---|
| pack-priv int compile(Bytecode code) throws CannotCompileException Overrides javassist.
| |
| constDescriptor | back to summary |
|---|---|
| pack-priv String constDescriptor() Overrides javassist. Doc from javassist. Returns the descriptor for constructors.
| |
| descriptor | back to summary |
|---|---|
| pack-priv String descriptor() Overrides javassist.
| |