|
bcel API: Class MethodGen
org.apache.bcel.generic
|
Fields inherited from class org.apache.bcel.generic.FieldGenOrMethodGen |
cp, name, type |
Fields inherited from class org.apache.bcel.classfile.AccessFlags |
access_flags |
Constructor Summary | |
MethodGen(int access_flags,
Type return_type,
Type[] arg_types,
java.lang.String[] arg_names,
java.lang.String method_name,
java.lang.String class_name,
InstructionList il,
ConstantPoolGen cp)
Declare method. |
|
MethodGen(Method m,
java.lang.String class_name,
ConstantPoolGen cp)
Instantiate from existing method. |
Method Summary | |
void |
addCodeAttribute(Attribute a)
Add an attribute to the code. |
void |
addException(java.lang.String class_name)
Add an exception possibly thrown by this method. |
CodeExceptionGen |
addExceptionHandler(InstructionHandle start_pc,
InstructionHandle end_pc,
InstructionHandle handler_pc,
ObjectType catch_type)
Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling is done. |
LineNumberGen |
addLineNumber(InstructionHandle ih,
int src_line)
Give an instruction a line number corresponding to the source code line. |
LocalVariableGen |
addLocalVariable(java.lang.String name,
Type type,
InstructionHandle start,
InstructionHandle end)
Adds a local variable to this method and assigns an index automatically. |
LocalVariableGen |
addLocalVariable(java.lang.String name,
Type type,
int slot,
InstructionHandle start,
InstructionHandle end)
Adds a local variable to this method. |
void |
addObserver(MethodObserver o)
Add observer for this object. |
MethodGen |
copy(java.lang.String class_name,
ConstantPoolGen cp)
|
java.lang.String |
getArgumentName(int i)
|
java.lang.String[] |
getArgumentNames()
|
Type |
getArgumentType(int i)
|
Type[] |
getArgumentTypes()
|
java.lang.String |
getClassName()
|
Attribute[] |
getCodeAttributes()
|
CodeExceptionGen[] |
getExceptionHandlers()
|
java.lang.String[] |
getExceptions()
|
InstructionList |
getInstructionList()
|
LineNumberGen[] |
getLineNumbers()
|
LineNumberTable |
getLineNumberTable(ConstantPoolGen cp)
|
LocalVariableGen[] |
getLocalVariables()
|
LocalVariableTable |
getLocalVariableTable(ConstantPoolGen cp)
|
int |
getMaxLocals()
|
int |
getMaxStack()
|
static int |
getMaxStack(ConstantPoolGen cp,
InstructionList il,
CodeExceptionGen[] et)
Computes stack usage of an instruction list by performing control flow analysis. |
Method |
getMethod()
Get method object. |
Type |
getReturnType()
|
java.lang.String |
getSignature()
|
void |
removeCodeAttribute(Attribute a)
Remove a code attribute. |
void |
removeCodeAttributes()
Remove all code attributes. |
void |
removeException(java.lang.String c)
Remove an exception. |
void |
removeExceptionHandler(CodeExceptionGen c)
Remove an exception handler. |
void |
removeExceptionHandlers()
Remove all line numbers. |
void |
removeExceptions()
Remove all exceptions. |
void |
removeLineNumber(LineNumberGen l)
Remove a line number. |
void |
removeLineNumbers()
Remove all line numbers. |
void |
removeLocalVariable(LocalVariableGen l)
Remove a local variable, its slot will not be reused, if you do not use addLocalVariable with an explicit index argument. |
void |
removeLocalVariables()
Remove all local variables. |
void |
removeNOPs()
Remove all NOPs from the instruction list (if possible) and update every object refering to them, i.e., branch instructions, local variables and exception handlers. |
void |
removeObserver(MethodObserver o)
Remove observer for this object. |
void |
setArgumentName(int i,
java.lang.String name)
|
void |
setArgumentNames(java.lang.String[] arg_names)
|
void |
setArgumentType(int i,
Type type)
|
void |
setArgumentTypes(Type[] arg_types)
|
void |
setClassName(java.lang.String class_name)
|
void |
setInstructionList(InstructionList il)
|
void |
setMaxLocals()
Compute maximum number of local variables. |
void |
setMaxLocals(int m)
Set maximum number of local variables. |
void |
setMaxStack()
Computes max. |
void |
setMaxStack(int m)
Set maximum stack size for this method. |
void |
setReturnType(Type return_type)
|
void |
stripAttributes(boolean flag)
Do not/Do produce attributes code attributesLineNumberTable and LocalVariableTable, like javac -O |
java.lang.String |
toString()
Return string representation close to declaration format, `public static void main(String[]) throws IOException', e.g. |
void |
update()
Call notify() method on all observers. |
Methods inherited from class org.apache.bcel.generic.FieldGenOrMethodGen |
addAttribute, clone, getAttributes, getConstantPool, getName, getType, removeAttribute, removeAttributes, setConstantPool, setName, setType |
Methods inherited from class org.apache.bcel.classfile.AccessFlags |
getAccessFlags, isAbstract, isAbstract, isFinal, isFinal, isInterface, isInterface, isNative, isNative, isPrivate, isPrivate, isProtected, isProtected, isPublic, isPublic, isStatic, isStatic, isStrictfp, isStrictfp, isSynchronized, isSynchronized, isTransient, isTransient, isVolatile, isVolatile, setAccessFlags |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MethodGen(int access_flags, Type return_type, Type[] arg_types, java.lang.String[] arg_names, java.lang.String method_name, java.lang.String class_name, InstructionList il, ConstantPoolGen cp)
access_flags
- access qualifiersreturn_type
- method typearg_types
- argument typesarg_names
- argument names (if this is null, default names will be provided
for them)method_name
- name of methodclass_name
- class name containing this method (may be null, if you don't care)il
- instruction list associated with this method, may be null only for
abstract or native methodscp
- constant poolpublic MethodGen(Method m, java.lang.String class_name, ConstantPoolGen cp)
m
- methodclass_name
- class name containing this methodcp
- constant poolMethod Detail |
public LocalVariableGen addLocalVariable(java.lang.String name, Type type, int slot, InstructionHandle start, InstructionHandle end)
name
- variable nametype
- variable typeslot
- the index of the local variable, if type is long or double, the next available
index is slot+2start
- from where the variable is validend
- until where the variable is validLocalVariable
public LocalVariableGen addLocalVariable(java.lang.String name, Type type, InstructionHandle start, InstructionHandle end)
name
- variable nametype
- variable typestart
- from where the variable is valid, if this is null,
it is valid from the startend
- until where the variable is valid, if this is null,
it is valid to the endLocalVariable
public void removeLocalVariable(LocalVariableGen l)
public void removeLocalVariables()
public LocalVariableGen[] getLocalVariables()
public LocalVariableTable getLocalVariableTable(ConstantPoolGen cp)
public LineNumberGen addLineNumber(InstructionHandle ih, int src_line)
ih
- instruction to tagLineNumber
public void removeLineNumber(LineNumberGen l)
public void removeLineNumbers()
public LineNumberGen[] getLineNumbers()
public LineNumberTable getLineNumberTable(ConstantPoolGen cp)
public CodeExceptionGen addExceptionHandler(InstructionHandle start_pc, InstructionHandle end_pc, InstructionHandle handler_pc, ObjectType catch_type)
start_pc
- Start of region (inclusive)end_pc
- End of region (inclusive)handler_pc
- Where handling is donecatch_type
- fully qualified class name of handled exception or null if any
exception is handledpublic void removeExceptionHandler(CodeExceptionGen c)
public void removeExceptionHandlers()
public CodeExceptionGen[] getExceptionHandlers()
public void addException(java.lang.String class_name)
class_name
- (fully qualified) name of exceptionpublic void removeException(java.lang.String c)
public void removeExceptions()
public java.lang.String[] getExceptions()
public void addCodeAttribute(Attribute a)
a
- attribute to be addedpublic void removeCodeAttribute(Attribute a)
public void removeCodeAttributes()
public Attribute[] getCodeAttributes()
public Method getMethod()
public void removeNOPs()
public void setMaxLocals(int m)
public int getMaxLocals()
public void setMaxStack(int m)
public int getMaxStack()
public java.lang.String getClassName()
public void setClassName(java.lang.String class_name)
public void setReturnType(Type return_type)
public Type getReturnType()
public void setArgumentTypes(Type[] arg_types)
public Type[] getArgumentTypes()
public void setArgumentType(int i, Type type)
public Type getArgumentType(int i)
public void setArgumentNames(java.lang.String[] arg_names)
public java.lang.String[] getArgumentNames()
public void setArgumentName(int i, java.lang.String name)
public java.lang.String getArgumentName(int i)
public InstructionList getInstructionList()
public void setInstructionList(InstructionList il)
public java.lang.String getSignature()
getSignature
in class FieldGenOrMethodGen
org.apache.bcel.generic.FieldGenOrMethodGen
public void setMaxStack()
public void setMaxLocals()
public void stripAttributes(boolean flag)
public static int getMaxStack(ConstantPoolGen cp, InstructionList il, CodeExceptionGen[] et)
public void addObserver(MethodObserver o)
public void removeObserver(MethodObserver o)
public void update()
public final java.lang.String toString()
toString
in class java.lang.Object
public MethodGen copy(java.lang.String class_name, ConstantPoolGen cp)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |