org.apache.bcel.generic
public class MethodGen extends FieldGenOrMethodGen
See Also: InstructionList Method
Constructor Summary | |
---|---|
MethodGen(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, InstructionList il, ConstantPoolGen cp)
Declare method. | |
MethodGen(Method m, String class_name, ConstantPoolGen cp)
Instantiate from existing method.
|
Method Summary | |
---|---|
void | addCodeAttribute(Attribute a)
Add an attribute to the code. |
void | addException(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(String name, Type type, int slot, InstructionHandle start, InstructionHandle end)
Adds a local variable to this method.
|
LocalVariableGen | addLocalVariable(String name, Type type, InstructionHandle start, InstructionHandle end)
Adds a local variable to this method and assigns an index automatically.
|
void | addObserver(MethodObserver o) Add observer for this object. |
MethodGen | copy(String class_name, ConstantPoolGen cp) |
boolean | equals(Object obj)
Return value as defined by given BCELComparator strategy.
|
String | getArgumentName(int i) |
String[] | getArgumentNames() |
Type | getArgumentType(int i) |
Type[] | getArgumentTypes() |
String | getClassName() |
Attribute[] | getCodeAttributes() |
static BCELComparator | getComparator() |
CodeExceptionGen[] | getExceptionHandlers() |
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() |
String | getSignature() |
int | hashCode()
Return value as defined by given BCELComparator strategy.
|
void | removeCodeAttribute(Attribute a)
Remove a code attribute. |
void | removeCodeAttributes()
Remove all code attributes. |
void | removeException(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, String name) |
void | setArgumentNames(String[] arg_names) |
void | setArgumentType(int i, Type type) |
void | setArgumentTypes(Type[] arg_types) |
void | setClassName(String class_name) |
static void | setComparator(BCELComparator comparator) |
void | setInstructionList(InstructionList il) |
void | setMaxLocals(int m)
Set maximum number of local variables. |
void | setMaxLocals()
Compute maximum number of local variables. |
void | setMaxStack(int m)
Set maximum stack size for this method. |
void | setMaxStack()
Computes max. stack size by performing control flow analysis. |
void | setReturnType(Type return_type) |
void | stripAttributes(boolean flag) Do not/Do produce attributes code attributesLineNumberTable and
LocalVariableTable, like javac -O |
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. |
Parameters: access_flags access qualifiers return_type method type arg_types argument types arg_names argument names (if this is null, default names will be provided for them) method_name name of method class_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 methods cp constant pool
Parameters: m method class_name class name containing this method cp constant pool
Parameters: a attribute to be added
Parameters: class_name (fully qualified) name of exception
Parameters: start_pc Start of region (inclusive) end_pc End of region (inclusive) handler_pc Where handling is done catch_type class type of handled exception or null if any exception is handled
Returns: new exception handler object
Parameters: ih instruction to tag
Returns: new line number object
See Also: LineNumber
Parameters: name variable name type variable type slot the index of the local variable, if type is long or double, the next available index is slot+2 start from where the variable is valid end until where the variable is valid
Returns: new local variable object
See Also: LocalVariable
Parameters: name variable name type variable type start from where the variable is valid, if this is null, it is valid from the start end until where the variable is valid, if this is null, it is valid to the end
Returns: new local variable object
See Also: LocalVariable
Returns: deep copy of this method
See Also: java.lang.Object#equals(java.lang.Object)
Returns: class that contains this method
Returns: all attributes of this method.
Returns: Comparison strategy object
Returns: `LineNumberTable' attribute of all the local variables of this method.
Returns: `LocalVariableTable' attribute of all the local variables of this method.
Returns: maximum stack depth used by method
Returns: method object
See Also: java.lang.Object#hashCode()
Parameters: comparator Comparison strategy object
Returns: String representation of the method.