public class MethodEditor extends java.lang.Object implements Opcode
MethodInfo,
Label,
Instruction| Modifier and Type | Field and Description |
|---|---|
static boolean |
OPT_STACK_2 |
static boolean |
PRESERVE_DEBUG |
UseMap |
uMap |
static boolean |
UNIQUE_HANDLERS |
opc_aaload, opc_aastore, opc_aconst_null, opc_aload, opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3, opc_anewarray, opc_areturn, opc_arraylength, opc_astore, opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3, opc_aswizzle, opc_aswrange, opc_athrow, opc_aupdate, opc_baload, opc_bastore, opc_bipush, opc_breakpoint, opc_caload, opc_castore, opc_checkcast, opc_d2f, opc_d2i, opc_d2l, opc_dadd, opc_daload, opc_dastore, opc_dcmpg, opc_dcmpl, opc_dconst_0, opc_dconst_1, opc_ddiv, opc_dload, opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3, opc_dmul, opc_dneg, opc_drem, opc_dreturn, opc_dstore, opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3, opc_dsub, opc_dup, opc_dup_x1, opc_dup_x2, opc_dup2, opc_dup2_x1, opc_dup2_x2, opc_f2d, opc_f2i, opc_f2l, opc_fadd, opc_faload, opc_fastore, opc_fcmpg, opc_fcmpl, opc_fconst_0, opc_fconst_1, opc_fconst_2, opc_fdiv, opc_fload, opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3, opc_fmul, opc_fneg, opc_frem, opc_freturn, opc_fstore, opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3, opc_fsub, opc_getfield, opc_getstatic, opc_goto, opc_goto_w, opc_i2b, opc_i2c, opc_i2d, opc_i2f, opc_i2l, opc_i2s, opc_iadd, opc_iaload, opc_iand, opc_iastore, opc_iconst_0, opc_iconst_1, opc_iconst_2, opc_iconst_3, opc_iconst_4, opc_iconst_5, opc_iconst_m1, opc_idiv, opc_if_acmpeq, opc_if_acmpne, opc_if_icmpeq, opc_if_icmpge, opc_if_icmpgt, opc_if_icmple, opc_if_icmplt, opc_if_icmpne, opc_ifeq, opc_ifge, opc_ifgt, opc_ifle, opc_iflt, opc_ifne, opc_ifnonnull, opc_ifnull, opc_iinc, opc_iload, opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3, opc_imul, opc_ineg, opc_instanceof, opc_invokeinterface, opc_invokespecial, opc_invokestatic, opc_invokevirtual, opc_ior, opc_irem, opc_ireturn, opc_ishl, opc_ishr, opc_istore, opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3, opc_isub, opc_iushr, opc_ixor, opc_jsr, opc_jsr_w, opc_l2d, opc_l2f, opc_l2i, opc_ladd, opc_laload, opc_land, opc_lastore, opc_lcmp, opc_lconst_0, opc_lconst_1, opc_ldc, opc_ldc_w, opc_ldc2_w, opc_ldiv, opc_lload, opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3, opc_lmul, opc_lneg, opc_lookupswitch, opc_lor, opc_lrem, opc_lreturn, opc_lshl, opc_lshr, opc_lstore, opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3, opc_lsub, opc_lushr, opc_lxor, opc_monitorenter, opc_monitorexit, opc_multianewarray, opc_new, opc_newarray, opc_nop, opc_pop, opc_pop2, opc_putfield, opc_putfield_nowb, opc_putstatic, opc_putstatic_nowb, opc_rc, opc_ret, opc_return, opc_saload, opc_sastore, opc_sipush, opc_supdate, opc_swap, opc_tableswitch, opc_wide, opc_xxxunusedxxx, opcNames, opcSize, opcx_aaload, opcx_aastore, opcx_aload, opcx_areturn, opcx_arraylength, opcx_astore, opcx_aswizzle, opcx_aswrange, opcx_athrow, opcx_aupdate, opcx_baload, opcx_bastore, opcx_caload, opcx_castore, opcx_checkcast, opcx_d2f, opcx_d2i, opcx_d2l, opcx_dadd, opcx_daload, opcx_dastore, opcx_dcmpg, opcx_dcmpl, opcx_ddiv, opcx_dload, opcx_dmul, opcx_dneg, opcx_drem, opcx_dreturn, opcx_dstore, opcx_dsub, opcx_dup, opcx_dup_x1, opcx_dup_x2, opcx_dup2, opcx_dup2_x1, opcx_dup2_x2, opcx_f2d, opcx_f2i, opcx_f2l, opcx_fadd, opcx_faload, opcx_fastore, opcx_fcmpg, opcx_fcmpl, opcx_fdiv, opcx_fload, opcx_fmul, opcx_fneg, opcx_frem, opcx_freturn, opcx_fstore, opcx_fsub, opcx_getfield, opcx_getstatic, opcx_goto, opcx_i2b, opcx_i2c, opcx_i2d, opcx_i2f, opcx_i2l, opcx_i2s, opcx_iadd, opcx_iaload, opcx_iand, opcx_iastore, opcx_idiv, opcx_if_acmpeq, opcx_if_acmpne, opcx_if_icmpeq, opcx_if_icmpge, opcx_if_icmpgt, opcx_if_icmple, opcx_if_icmplt, opcx_if_icmpne, opcx_ifeq, opcx_ifge, opcx_ifgt, opcx_ifle, opcx_iflt, opcx_ifne, opcx_ifnonnull, opcx_ifnull, opcx_iinc, opcx_iload, opcx_imul, opcx_ineg, opcx_instanceof, opcx_invokeinterface, opcx_invokespecial, opcx_invokestatic, opcx_invokevirtual, opcx_ior, opcx_irem, opcx_ireturn, opcx_ishl, opcx_ishr, opcx_istore, opcx_isub, opcx_iushr, opcx_ixor, opcx_jsr, opcx_l2d, opcx_l2f, opcx_l2i, opcx_ladd, opcx_laload, opcx_land, opcx_lastore, opcx_lcmp, opcx_ldc, opcx_ldiv, opcx_lload, opcx_lmul, opcx_lneg, opcx_lor, opcx_lrem, opcx_lreturn, opcx_lshl, opcx_lshr, opcx_lstore, opcx_lsub, opcx_lushr, opcx_lxor, opcx_monitorenter, opcx_monitorexit, opcx_multianewarray, opcx_new, opcx_newarray, opcx_nop, opcx_pop, opcx_pop2, opcx_putfield, opcx_putfield_nowb, opcx_putstatic, opcx_putstatic_nowb, opcx_rc, opcx_ret, opcx_return, opcx_saload, opcx_sastore, opcx_supdate, opcx_swap, opcx_switch, opcXMap, VARIABLE| Constructor and Description |
|---|
MethodEditor(ClassEditor editor,
int modifiers,
java.lang.Class returnType,
java.lang.String methodName,
java.lang.Class[] paramTypes,
java.lang.Class[] exceptionTypes) |
MethodEditor(ClassEditor editor,
int modifiers,
Type returnType,
java.lang.String methodName,
Type[] paramTypes,
Type[] exceptionTypes)
Creates a new
MethodEditor for editing a method in a given
class with the given modifiers, return type, name, parameter types, and
exception types. |
MethodEditor(ClassEditor editor,
MethodInfo methodInfo)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInstruction(Instruction inst)
Add an instruction to the end of the code array.
|
void |
addInstruction(int opcodeClass)
Add an instruction.
|
void |
addInstruction(int opcodeClass,
java.lang.Object operand)
Add an instruction.
|
void |
addLabel(Label label)
Add a label to the code array to the end of the code array.
|
void |
addLineNumberEntry(Label label,
int lineNumber)
Add a line number entry.
|
void |
addTryCatch(TryCatch tryCatch)
Add an exception handler.
|
void |
clearCode()
Remove all the instructions in preparation for the instructions being
added back after a control flow graph edit.
|
void |
clearCode2()
Like clear code, but doesn't reset the maxLocals.
|
java.util.List |
code()
Returns the code (Instructions and Labels) in
the method.
|
java.lang.Object |
codeElementAt(int i)
Returns a Label or Instruction in the code array.
|
int |
codeLength()
Get the length of the code array.
|
void |
commit()
Commits changes made to this MethodEditor back to the MethodInfo on which
it is based.
|
ClassEditor |
declaringClass()
Returns the class which declared the method.
|
void |
delete()
Marks this method for deletion.
|
boolean |
equals(java.lang.Object o)
Two MethodEditors are equal if they edit the same method in
the same class.
|
Type[] |
exceptions()
Returns the Types of exceptions that this method may throw.
|
Label |
firstBlock()
Get the label of the first block.
|
int |
hashCode()
A MethodEditor's hash code is based on the hash codes for its
class, name, and type.
|
void |
insertCodeAt(java.lang.Object obj,
int i)
Inserts a Label or Instruction into the code array.
|
boolean |
isAbstract() |
boolean |
isConstructor()
Returns true if the method being edited is a constructor.
|
boolean |
isDirty()
Returns true if this method has been modified.
|
boolean |
isFinal() |
boolean |
isInterface()
Returns true if this method's class is an interface.
|
boolean |
isNative() |
boolean |
isPackage()
Returns true is the method has package level visibility
|
boolean |
isPrivate() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isSynchronized() |
LocalVariable |
localAt(int index)
Returns the LocalVariable with the given index.
|
int |
maxLocals()
Returns the maximum number of locals used by the method.
|
MemberRef |
memberRef()
Returns a MemberRef for the method.
|
MethodInfo |
methodInfo()
Returns the raw MethodInfo of the method being edited.
|
java.lang.String |
name()
Returns the name of the method.
|
NameAndType |
nameAndType()
Returns the NameAndType of the method.
|
Label |
newLabel()
Get the next available label.
|
Label |
newLabelTrue() |
LocalVariable |
newLocal(boolean isWide)
Creates a new local variable of an undertermined type.
|
LocalVariable |
newLocal(Type type)
Creates a new local variable.
|
Label |
nextBlock(Label label)
Get the label of the next block after the parameter.
|
int |
numTryCatches()
Returns the number of exception handlers in the method.
|
LocalVariable |
paramAt(int index)
Get the LocalVariable for the parameter at the given index.
|
Type[] |
paramTypes()
Returns an array of Types representing the types of the
parameters of this method.
|
void |
print(java.io.PrintStream out)
Print the method.
|
void |
rememberDef(LocalExpr e) |
void |
removeCodeAt(int i)
Removes a Label or Instruction from the code array.
|
void |
replaceCodeAt(java.lang.Object obj,
int i)
Replace a Label or Instruction in the code array.
|
void |
setAbstract(boolean flag) |
void |
setCode(java.util.List v) |
void |
setDirty(boolean dirty)
Sets the dirty flag of this method.
|
void |
setFinal(boolean flag) |
void |
setNative(boolean flag) |
void |
setPrivate(boolean flag) |
void |
setProtected(boolean flag) |
void |
setPublic(boolean flag) |
void |
setStatic(boolean flag) |
void |
setSynchronized(boolean flag) |
java.lang.String |
toString() |
java.util.Collection |
tryCatches()
Returns the exception handlers (TryCatch) in the method.
|
Type |
type()
Returns the type of the method.
|
UseMap |
uMap() |
public static boolean PRESERVE_DEBUG
public static boolean UNIQUE_HANDLERS
public static boolean OPT_STACK_2
public UseMap uMap
public MethodEditor(ClassEditor editor, int modifiers, java.lang.Class returnType, java.lang.String methodName, java.lang.Class[] paramTypes, java.lang.Class[] exceptionTypes)
public MethodEditor(ClassEditor editor, int modifiers, Type returnType, java.lang.String methodName, Type[] paramTypes, Type[] exceptionTypes)
MethodEditor for editing a method in a given
class with the given modifiers, return type, name, parameter types, and
exception types.modifiers - The modifiers
for the new methodreturnType - The return type of the method. If, returnType
is null, the return type is assumed to be void.methodName - The name of the methodparamTypes - The types of the parameters to the new method. If
paramTypes is null, then we
assume that there are no arguments.exceptionTypes - The types of exceptions that may be thrown by the new method.
If exceptionTypes is null, then
we assume that no exceptions are declared.public MethodEditor(ClassEditor editor, MethodInfo methodInfo)
editor - The class containing the method.methodInfo - The method to edit.ClassEditor,
MethodInfopublic Type[] exceptions()
public boolean isDirty()
public void setDirty(boolean dirty)
public void delete()
IllegalStateException.public Type[] paramTypes()
public LocalVariable paramAt(int index)
index - The index into the params (0 is the this pointer or the first
argument, if static).public MethodInfo methodInfo()
public ClassEditor declaringClass()
public int maxLocals()
public boolean isPublic()
public boolean isPrivate()
public boolean isProtected()
public boolean isPackage()
public boolean isStatic()
public boolean isFinal()
public boolean isSynchronized()
public boolean isNative()
public boolean isAbstract()
public boolean isInterface()
public void setPublic(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setPrivate(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setProtected(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setStatic(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setFinal(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setSynchronized(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setNative(boolean flag)
java.lang.IllegalStateException - This field has been marked for deletionpublic void setAbstract(boolean flag)
public void clearCode()
java.lang.IllegalStateException - This field has been marked for deletionpublic void clearCode2()
public java.lang.String name()
public boolean isConstructor()
public Type type()
public NameAndType nameAndType()
public MemberRef memberRef()
public int codeLength()
public void setCode(java.util.List v)
java.lang.IllegalStateException - This field has been marked for deletionpublic java.util.List code()
public Label firstBlock()
public Label nextBlock(Label label)
label - The label at which to begin.public void removeCodeAt(int i)
i - The index of the element to remove.java.lang.IllegalStateException - This field has been marked for deletionpublic void insertCodeAt(java.lang.Object obj,
int i)
i - The index of the element to insert before.java.lang.IllegalStateException - This field has been marked for deletionpublic void replaceCodeAt(java.lang.Object obj,
int i)
obj - The new element.i - The index of the element to replacejava.lang.IllegalStateException - This field has been marked for deletionpublic java.lang.Object codeElementAt(int i)
i - The index into the code array.public void addLineNumberEntry(Label label, int lineNumber)
label - The label beginning the range of instructions for this line
number.lineNumber - The line number.java.lang.IllegalStateException - This field has been marked for deletionpublic int numTryCatches()
public java.util.Collection tryCatches()
public void addTryCatch(TryCatch tryCatch)
tryCatch - An exception handler.java.lang.IllegalStateException - This field has been marked for deletionpublic LocalVariable newLocal(Type type)
public LocalVariable newLocal(boolean isWide)
java.lang.IllegalStateException - This field has been marked for deletionpublic LocalVariable localAt(int index)
public void addInstruction(int opcodeClass)
opcodeClass - The instruction to add.public void addInstruction(int opcodeClass,
java.lang.Object operand)
opcodeClass - The instruction to add.public void addInstruction(Instruction inst)
inst - The instruction to add.java.lang.IllegalStateException - This field has been marked for deletionpublic Label newLabel()
java.lang.IllegalStateException - This field has been marked for deletionpublic Label newLabelTrue()
public void addLabel(Label label)
label - The label to add.java.lang.IllegalStateException - This field has been marked for deletionpublic void commit()
public void print(java.io.PrintStream out)
out - Stream to which to print.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic UseMap uMap()
public void rememberDef(LocalExpr e)