Package org.jboss.byteman.agent.adapter
Class RuleGeneratorAdapter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.jboss.byteman.agent.adapter.RuleMethodAdapter
-
- org.jboss.byteman.agent.adapter.RuleGeneratorAdapter
-
- Direct Known Subclasses:
RuleTriggerMethodAdapter
public class RuleGeneratorAdapter extends RuleMethodAdapter
A modified version of the asm 3.0 GeneratorAdapter class which dispatches calls to methods of MethodVisitor to this rather than to the encapsulated MethodVisitor instance in field mv. Doing so gives the current instance a chance to observe all visit operations. Without it the current instance only sees visit operations invoked directly by previous visitors in the chain. This is necessary in order for the RuleTriggerAdapter to build a complete CFG for the method being visited. As a consequence of the above change this class cannot inherit the methods from LocalVariableSorter which allow introduction of new local variables. That's not actually much of a loss since the functionality provided by that class is of limited utility -- it only allows local variables to be introduced via a prior pipeline stage. Instead this class provides methods to track the number of locals employed so far and supports temporary introduction and removal of locals inside injected trigger or handler code. See methodsnewLocal(org.objectweb.asm.Type),popLocal(int),loadLocal(int)andstoreLocal(int). Another reason to transplant code to this class is because it inherits functionality from RuleMethodAdapter which is used by RuleCheckAdapter and RuleTriggerAdapter to identify and classify local variables but provides functionality to modify bytecode which is only needed by RuleTriggerAdapter. So, the original class would have needed reparenting anyway.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
RuleMethodAdapter.LocalVar
-
-
Field Summary
Fields Modifier and Type Field Description static intADDConstant for themathmethod.static intANDConstant for themathmethod.private org.objectweb.asm.Type[]argumentTypesArgument types of the method visited by this adapter.private static org.objectweb.asm.TypeBOOLEAN_TYPEprivate static org.objectweb.asm.commons.MethodBOOLEAN_VALUEprivate static org.objectweb.asm.TypeBYTE_TYPEprivate static org.objectweb.asm.commons.MethodCHAR_VALUEprivate static org.objectweb.asm.TypeCHARACTER_TYPEprivate static java.lang.StringCLDESCstatic intDIVConstant for themathmethod.private static org.objectweb.asm.TypeDOUBLE_TYPEprivate static org.objectweb.asm.commons.MethodDOUBLE_VALUEstatic intEQConstant for theifCmpmethod.private static org.objectweb.asm.TypeFLOAT_TYPEprivate static org.objectweb.asm.commons.MethodFLOAT_VALUEstatic intGEConstant for theifCmpmethod.static intGTConstant for theifCmpmethod.private static org.objectweb.asm.commons.MethodINT_VALUEprivate static org.objectweb.asm.TypeINTEGER_TYPEstatic intLEConstant for theifCmpmethod.private intlocalHighWaterused to track maximum number of local variable slotsprivate java.util.ListlocalTypesTypes of the local variables of the method visited by this adapter.private static org.objectweb.asm.TypeLONG_TYPEprivate static org.objectweb.asm.commons.MethodLONG_VALUEstatic intLTConstant for theifCmpmethod.static intMULConstant for themathmethod.static intNEConstant for theifCmpmethod.static intNEGConstant for themathmethod.private intnextLocalused to track active local variable slotsprivate static org.objectweb.asm.TypeNUMBER_TYPEprivate static org.objectweb.asm.TypeOBJECT_TYPEstatic intORConstant for themathmethod.static intREMConstant for themathmethod.private org.objectweb.asm.TypereturnTypeReturn type of the method visited by this adapter.static intSHLConstant for themathmethod.private static org.objectweb.asm.TypeSHORT_TYPEstatic intSHRConstant for themathmethod.static intSUBConstant for themathmethod.static intUSHRConstant for themathmethod.static intXORConstant for themathmethod.-
Fields inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
access, descriptor, localVarsByName, name, rule, transformContext
-
-
Constructor Summary
Constructors Constructor Description RuleGeneratorAdapter(org.objectweb.asm.MethodVisitor mv, TransformContext transformContext, int access, java.lang.String name, java.lang.String desc, Rule rule)Creates a newRuleGeneratorAdapter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarrayLength()Generates the instruction to compute the length of an array.voidarrayLoad(org.objectweb.asm.Type type)Generates the instruction to load an element from an array.voidarrayStore(org.objectweb.asm.Type type)Generates the instruction to store an element in an array.voidbox(org.objectweb.asm.Type type)Generates the instructions to box the top stack value.voidcast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)Generates the instructions to cast a numerical value from one type to another.voidcatchException(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Type exception)Marks the start of an exception handler.voidcheckCast(org.objectweb.asm.Type type)Generates the instruction to check that the top stack value is of the given type.private voiddumpFrame(int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)private voiddumpType(java.lang.StringBuffer buffer, java.lang.Object t)voiddup()Generates a DUP instruction.voiddup2()Generates a DUP2 instruction.voiddup2X1()Generates a DUP2_X1 instruction.voiddup2X2()Generates a DUP2_X2 instruction.voiddupX1()Generates a DUP_X1 instruction.voiddupX2()Generates a DUP_X2 instruction.voidendMethod()Marks the end of the visited method.private voidfieldInsn(int opcode, org.objectweb.asm.Type ownerType, java.lang.String name, org.objectweb.asm.Type fieldType)Generates a get field or set field instruction.private intgetArgIndex(int arg)Returns the index of the given method argument in the frame's local variables array.voidgetField(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to push the value of a non static field on the stack.private static java.lang.String[]getInternalNames(org.objectweb.asm.Type[] types)Returns the internal names of the given types.org.objectweb.asm.TypegetLocalType(int local)voidgetStatic(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to push the value of a static field on the stack.voidgoTo(org.objectweb.asm.Label label)Generates the instruction to jump to the given label.voidifCmp(org.objectweb.asm.Type type, int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top two stack values.voidifICmp(int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top two integer stack values.voidifNonNull(org.objectweb.asm.Label label)Generates the instruction to jump to the given label if the top stack value is not null.voidifNull(org.objectweb.asm.Label label)Generates the instruction to jump to the given label if the top stack value is null.voidifZCmp(int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top integer stack value with zero.voidiinc(int local, int amount)Generates the instruction to increment the given local variable.private voidinitLocalTypes()initialise the local slot types array with the types of the method target and parameters.voidinstanceOf(org.objectweb.asm.Type type)Generates the instruction to test if the top stack value is of the given type.voidinvokeConstructor(org.objectweb.asm.Type type, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a constructor.voidinvokeDynamic(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)Generates an invokedynamic instruction.private voidinvokeInsn(int opcode, org.objectweb.asm.Type type, org.objectweb.asm.commons.Method method, boolean itf)Generates an invoke method instruction.voidinvokeInterface(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke an interface method.voidinvokeStatic(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a static method.voidinvokeVirtual(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a normal method.voidloadArg(int arg)Generates the instruction to load the given method argument on the stack.voidloadArgArray()Generates the instructions to load all the method arguments on the stack, as a single object array.voidloadArgs()Generates the instructions to load all the method arguments on the stack.voidloadArgs(int arg, int count)Generates the instructions to load the given method arguments on the stack.private voidloadInsn(org.objectweb.asm.Type type, int index)Generates the instruction to push a local variable on the stack.voidloadLocal(int local)load a value onto the stack from a local var slot which can obtained from a call to newLocal or from a lcoal variable table entry.voidloadThis()Generates the instruction to load 'this' on the stack.org.objectweb.asm.Labelmark()Marks the current code position with a new label.voidmark(org.objectweb.asm.Label label)Marks the current code position with the given label.voidmath(int op, org.objectweb.asm.Type type)Generates the instruction to do the specified mathematical or logical operation.voidmonitorEnter()Generates the instruction to get the monitor of the top stack value.voidmonitorExit()Generates the instruction to release the monitor of the top stack value.voidnewArray(org.objectweb.asm.Type type)Generates the instruction to create a new array.voidnewInstance(org.objectweb.asm.Type type)Generates the instruction to create a new object.org.objectweb.asm.LabelnewLabel()Creates a newLabel.intnewLocal(org.objectweb.asm.Type valueType)return a new local slot index for a local var not currently in use.voidnot()Generates the instructions to compute the bitwise negation of the top stack value.voidpop()Generates a POP instruction.voidpop2()Generates a POP2 instruction.voidpopLocal(int local)free a previously allocated local slotvoidpush(boolean value)Generates the instruction to push the given value on the stack.voidpush(double value)Generates the instruction to push the given value on the stack.voidpush(float value)Generates the instruction to push the given value on the stack.voidpush(int value)Generates the instruction to push the given value on the stack.voidpush(long value)Generates the instruction to push the given value on the stack.voidpush(java.lang.String value)Generates the instruction to push the given value on the stack.voidpush(org.objectweb.asm.Handle handle)Generates the instruction to push a handle on the stack.voidpush(org.objectweb.asm.Type value)Generates the instruction to push the given value on the stack.voidputField(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to store the top stack value in a non static field.voidputStatic(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to store the top stack value in a static field.voidret(int local)Generates a RET instruction.voidreturnValue()Generates the instruction to return the top stack value to the caller.voidstoreArg(int arg)Generates the instruction to store the top stack value in the given method argument.private voidstoreInsn(org.objectweb.asm.Type type, int index)Generates the instruction to store the top stack value in a local variable.voidstoreLocal(int local)save a value on the stack to a local var slotvoidswap()Generates a SWAP instruction.voidswap(org.objectweb.asm.Type prev, org.objectweb.asm.Type type)Generates the instructions to swap the top two stack values.voidtableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator)Generates the instructions for a switch statement.voidtableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator, boolean useTable)Generates the instructions for a switch statement.voidthrowException()Generates the instruction to throw an exception.voidthrowException(org.objectweb.asm.Type type, java.lang.String msg)Generates the instructions to create and throw an exception.private voidtypeInsn(int opcode, org.objectweb.asm.Type type)Generates a type dependent instruction.voidunbox(org.objectweb.asm.Type type)Generates the instructions to unbox the top stack value.voidvisitFrame(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)voidvisitMaxs(int maxStack, int maxLocals)ensure we allow enough room for any extra locals on the stackvoidvisitVarInsn(int opcode, int var)override this so we can see track which local var slots are in use and avoid overwriting them-
Methods inherited from class org.jboss.byteman.agent.adapter.RuleMethodAdapter
getTriggerClassName, lookup, visitLocalVariable
-
Methods inherited from class org.objectweb.asm.MethodVisitor
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitIincInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn
-
-
-
-
Field Detail
-
CLDESC
private static final java.lang.String CLDESC
- See Also:
- Constant Field Values
-
BYTE_TYPE
private static final org.objectweb.asm.Type BYTE_TYPE
-
BOOLEAN_TYPE
private static final org.objectweb.asm.Type BOOLEAN_TYPE
-
SHORT_TYPE
private static final org.objectweb.asm.Type SHORT_TYPE
-
CHARACTER_TYPE
private static final org.objectweb.asm.Type CHARACTER_TYPE
-
INTEGER_TYPE
private static final org.objectweb.asm.Type INTEGER_TYPE
-
FLOAT_TYPE
private static final org.objectweb.asm.Type FLOAT_TYPE
-
LONG_TYPE
private static final org.objectweb.asm.Type LONG_TYPE
-
DOUBLE_TYPE
private static final org.objectweb.asm.Type DOUBLE_TYPE
-
NUMBER_TYPE
private static final org.objectweb.asm.Type NUMBER_TYPE
-
OBJECT_TYPE
private static final org.objectweb.asm.Type OBJECT_TYPE
-
BOOLEAN_VALUE
private static final org.objectweb.asm.commons.Method BOOLEAN_VALUE
-
CHAR_VALUE
private static final org.objectweb.asm.commons.Method CHAR_VALUE
-
INT_VALUE
private static final org.objectweb.asm.commons.Method INT_VALUE
-
FLOAT_VALUE
private static final org.objectweb.asm.commons.Method FLOAT_VALUE
-
LONG_VALUE
private static final org.objectweb.asm.commons.Method LONG_VALUE
-
DOUBLE_VALUE
private static final org.objectweb.asm.commons.Method DOUBLE_VALUE
-
ADD
public static final int ADD
Constant for themathmethod.- See Also:
- Constant Field Values
-
SUB
public static final int SUB
Constant for themathmethod.- See Also:
- Constant Field Values
-
MUL
public static final int MUL
Constant for themathmethod.- See Also:
- Constant Field Values
-
DIV
public static final int DIV
Constant for themathmethod.- See Also:
- Constant Field Values
-
REM
public static final int REM
Constant for themathmethod.- See Also:
- Constant Field Values
-
NEG
public static final int NEG
Constant for themathmethod.- See Also:
- Constant Field Values
-
SHL
public static final int SHL
Constant for themathmethod.- See Also:
- Constant Field Values
-
SHR
public static final int SHR
Constant for themathmethod.- See Also:
- Constant Field Values
-
USHR
public static final int USHR
Constant for themathmethod.- See Also:
- Constant Field Values
-
AND
public static final int AND
Constant for themathmethod.- See Also:
- Constant Field Values
-
OR
public static final int OR
Constant for themathmethod.- See Also:
- Constant Field Values
-
XOR
public static final int XOR
Constant for themathmethod.- See Also:
- Constant Field Values
-
EQ
public static final int EQ
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
NE
public static final int NE
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
LT
public static final int LT
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
GE
public static final int GE
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
GT
public static final int GT
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
LE
public static final int LE
Constant for theifCmpmethod.- See Also:
- Constant Field Values
-
argumentTypes
private final org.objectweb.asm.Type[] argumentTypes
Argument types of the method visited by this adapter.
-
returnType
private final org.objectweb.asm.Type returnType
Return type of the method visited by this adapter.
-
localTypes
private final java.util.List localTypes
Types of the local variables of the method visited by this adapter.
-
nextLocal
private int nextLocal
used to track active local variable slots
-
localHighWater
private int localHighWater
used to track maximum number of local variable slots
-
-
Constructor Detail
-
RuleGeneratorAdapter
public RuleGeneratorAdapter(org.objectweb.asm.MethodVisitor mv, TransformContext transformContext, int access, java.lang.String name, java.lang.String desc, Rule rule)Creates a newRuleGeneratorAdapter.- Parameters:
mv- the method visitor to which this adapter delegates calls.access- the method's access flags (seeOpcodes).name- the method's name.desc- the method's descriptor (seeType).transformContext- the current transform contextrule- the rule currently being injected
-
-
Method Detail
-
initLocalTypes
private void initLocalTypes()
initialise the local slot types array with the types of the method target and parameters. this is needed because we are only sent an initial frame identifying the local slots which belong to the method if a stackmap table has been included in the bytecode and this is nto always the case.
-
getInternalNames
private static java.lang.String[] getInternalNames(org.objectweb.asm.Type[] types)
Returns the internal names of the given types.- Parameters:
types- a set of types.- Returns:
- the internal names of the given types.
-
push
public void push(boolean value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(int value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(long value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(float value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(double value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(java.lang.String value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack. May be null.
-
push
public void push(org.objectweb.asm.Type value)
Generates the instruction to push the given value on the stack.- Parameters:
value- the value to be pushed on the stack.
-
push
public void push(org.objectweb.asm.Handle handle)
Generates the instruction to push a handle on the stack.- Parameters:
handle- the handle to be pushed on the stack.
-
getArgIndex
private int getArgIndex(int arg)
Returns the index of the given method argument in the frame's local variables array.- Parameters:
arg- the index of a method argument.- Returns:
- the index of the given method argument in the frame's local variables array.
-
loadInsn
private void loadInsn(org.objectweb.asm.Type type, int index)Generates the instruction to push a local variable on the stack.- Parameters:
type- the type of the local variable to be loaded.index- an index in the frame's local variables array.
-
storeInsn
private void storeInsn(org.objectweb.asm.Type type, int index)Generates the instruction to store the top stack value in a local variable.- Parameters:
type- the type of the local variable to be stored.index- an index in the frame's local variables array.
-
loadThis
public void loadThis()
Generates the instruction to load 'this' on the stack.
-
loadArg
public void loadArg(int arg)
Generates the instruction to load the given method argument on the stack.- Parameters:
arg- the index of a method argument.
-
loadArgs
public void loadArgs(int arg, int count)Generates the instructions to load the given method arguments on the stack.- Parameters:
arg- the index of the first method argument to be loaded.count- the number of method arguments to be loaded.
-
loadArgs
public void loadArgs()
Generates the instructions to load all the method arguments on the stack.
-
loadArgArray
public void loadArgArray()
Generates the instructions to load all the method arguments on the stack, as a single object array.
-
storeArg
public void storeArg(int arg)
Generates the instruction to store the top stack value in the given method argument.- Parameters:
arg- the index of a method argument.
-
arrayLoad
public void arrayLoad(org.objectweb.asm.Type type)
Generates the instruction to load an element from an array.- Parameters:
type- the type of the array element to be loaded.
-
arrayStore
public void arrayStore(org.objectweb.asm.Type type)
Generates the instruction to store an element in an array.- Parameters:
type- the type of the array element to be stored.
-
pop
public void pop()
Generates a POP instruction.
-
pop2
public void pop2()
Generates a POP2 instruction.
-
dup
public void dup()
Generates a DUP instruction.
-
dup2
public void dup2()
Generates a DUP2 instruction.
-
dupX1
public void dupX1()
Generates a DUP_X1 instruction.
-
dupX2
public void dupX2()
Generates a DUP_X2 instruction.
-
dup2X1
public void dup2X1()
Generates a DUP2_X1 instruction.
-
dup2X2
public void dup2X2()
Generates a DUP2_X2 instruction.
-
swap
public void swap()
Generates a SWAP instruction.
-
swap
public void swap(org.objectweb.asm.Type prev, org.objectweb.asm.Type type)Generates the instructions to swap the top two stack values.- Parameters:
prev- type of the top - 1 stack value.type- type of the top stack value.
-
math
public void math(int op, org.objectweb.asm.Type type)Generates the instruction to do the specified mathematical or logical operation.- Parameters:
op- a mathematical or logical operation. Must be one of ADD, SUB, MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR.type- the type of the operand(s) for this operation.
-
not
public void not()
Generates the instructions to compute the bitwise negation of the top stack value.
-
iinc
public void iinc(int local, int amount)Generates the instruction to increment the given local variable.- Parameters:
local- the local variable to be incremented.amount- the amount by which the local variable must be incremented.
-
cast
public void cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)Generates the instructions to cast a numerical value from one type to another.- Parameters:
from- the type of the top stack valueto- the type into which this value must be cast.
-
box
public void box(org.objectweb.asm.Type type)
Generates the instructions to box the top stack value. This value is replaced by its boxed equivalent on top of the stack.- Parameters:
type- the type of the top stack value.
-
unbox
public void unbox(org.objectweb.asm.Type type)
Generates the instructions to unbox the top stack value. This value is replaced by its unboxed equivalent on top of the stack.- Parameters:
type- the type of the top stack value.
-
newLabel
public org.objectweb.asm.Label newLabel()
Creates a newLabel.- Returns:
- a new
Label.
-
mark
public void mark(org.objectweb.asm.Label label)
Marks the current code position with the given label.- Parameters:
label- a label.
-
mark
public org.objectweb.asm.Label mark()
Marks the current code position with a new label.- Returns:
- the label that was created to mark the current code position.
-
ifCmp
public void ifCmp(org.objectweb.asm.Type type, int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top two stack values.- Parameters:
type- the type of the top two stack values.mode- how these values must be compared. One of EQ, NE, LT, GE, GT, LE.label- where to jump if the comparison result is true.
-
ifICmp
public void ifICmp(int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top two integer stack values.- Parameters:
mode- how these values must be compared. One of EQ, NE, LT, GE, GT, LE.label- where to jump if the comparison result is true.
-
ifZCmp
public void ifZCmp(int mode, org.objectweb.asm.Label label)Generates the instructions to jump to a label based on the comparison of the top integer stack value with zero.- Parameters:
mode- how these values must be compared. One of EQ, NE, LT, GE, GT, LE.label- where to jump if the comparison result is true.
-
ifNull
public void ifNull(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label if the top stack value is null.- Parameters:
label- where to jump if the condition is true.
-
ifNonNull
public void ifNonNull(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label if the top stack value is not null.- Parameters:
label- where to jump if the condition is true.
-
goTo
public void goTo(org.objectweb.asm.Label label)
Generates the instruction to jump to the given label.- Parameters:
label- where to jump if the condition is true.
-
ret
public void ret(int local)
Generates a RET instruction.- Parameters:
local- a local variable identifier, as returned bynewLocal().
-
tableSwitch
public void tableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator)Generates the instructions for a switch statement.- Parameters:
keys- the switch case keys.generator- a generator to generate the code for the switch cases.
-
tableSwitch
public void tableSwitch(int[] keys, org.objectweb.asm.commons.TableSwitchGenerator generator, boolean useTable)Generates the instructions for a switch statement.- Parameters:
keys- the switch case keys.generator- a generator to generate the code for the switch cases.useTable- true to use a TABLESWITCH instruction, or false to use a LOOKUPSWITCH instruction.
-
returnValue
public void returnValue()
Generates the instruction to return the top stack value to the caller.
-
fieldInsn
private void fieldInsn(int opcode, org.objectweb.asm.Type ownerType, java.lang.String name, org.objectweb.asm.Type fieldType)Generates a get field or set field instruction.- Parameters:
opcode- the instruction's opcode.ownerType- the class in which the field is defined.name- the name of the field.fieldType- the type of the field.
-
getStatic
public void getStatic(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to push the value of a static field on the stack.- Parameters:
owner- the class in which the field is defined.name- the name of the field.type- the type of the field.
-
putStatic
public void putStatic(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to store the top stack value in a static field.- Parameters:
owner- the class in which the field is defined.name- the name of the field.type- the type of the field.
-
getField
public void getField(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to push the value of a non static field on the stack.- Parameters:
owner- the class in which the field is defined.name- the name of the field.type- the type of the field.
-
putField
public void putField(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)Generates the instruction to store the top stack value in a non static field.- Parameters:
owner- the class in which the field is defined.name- the name of the field.type- the type of the field.
-
invokeInsn
private void invokeInsn(int opcode, org.objectweb.asm.Type type, org.objectweb.asm.commons.Method method, boolean itf)Generates an invoke method instruction.- Parameters:
opcode- the instruction's opcode.type- the class in which the method is defined.method- the method to be invoked.
-
invokeVirtual
public void invokeVirtual(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a normal method.- Parameters:
owner- the class in which the method is defined.method- the method to be invoked.
-
invokeConstructor
public void invokeConstructor(org.objectweb.asm.Type type, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a constructor.- Parameters:
type- the class in which the constructor is defined.method- the constructor to be invoked.
-
invokeStatic
public void invokeStatic(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke a static method.- Parameters:
owner- the class in which the method is defined.method- the method to be invoked.
-
invokeInterface
public void invokeInterface(org.objectweb.asm.Type owner, org.objectweb.asm.commons.Method method)Generates the instruction to invoke an interface method.- Parameters:
owner- the class in which the method is defined.method- the method to be invoked.
-
invokeDynamic
public void invokeDynamic(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)Generates an invokedynamic instruction.- Parameters:
name- the method's name.desc- the method's descriptor (seeType).bsm- the bootstrap method.bsmArgs- the bootstrap method constant arguments. Each argument must be anInteger,Float,Long,Double,String,TypeorHandlevalue. This method is allowed to modify the content of the array so a caller should expect that this array may change.
-
typeInsn
private void typeInsn(int opcode, org.objectweb.asm.Type type)Generates a type dependent instruction.- Parameters:
opcode- the instruction's opcode.type- the instruction's operand.
-
newInstance
public void newInstance(org.objectweb.asm.Type type)
Generates the instruction to create a new object.- Parameters:
type- the class of the object to be created.
-
newArray
public void newArray(org.objectweb.asm.Type type)
Generates the instruction to create a new array.- Parameters:
type- the type of the array elements.
-
arrayLength
public void arrayLength()
Generates the instruction to compute the length of an array.
-
throwException
public void throwException()
Generates the instruction to throw an exception.
-
throwException
public void throwException(org.objectweb.asm.Type type, java.lang.String msg)Generates the instructions to create and throw an exception. The exception class must have a constructor with a single String argument.- Parameters:
type- the class of the exception to be thrown.msg- the detailed message of the exception.
-
checkCast
public void checkCast(org.objectweb.asm.Type type)
Generates the instruction to check that the top stack value is of the given type.- Parameters:
type- a class or interface type.
-
instanceOf
public void instanceOf(org.objectweb.asm.Type type)
Generates the instruction to test if the top stack value is of the given type.- Parameters:
type- a class or interface type.
-
monitorEnter
public void monitorEnter()
Generates the instruction to get the monitor of the top stack value.
-
monitorExit
public void monitorExit()
Generates the instruction to release the monitor of the top stack value.
-
endMethod
public void endMethod()
Marks the end of the visited method.
-
catchException
public void catchException(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Type exception)Marks the start of an exception handler.- Parameters:
start- beginning of the exception handler's scope (inclusive).end- end of the exception handler's scope (exclusive).exception- internal name of the type of exceptions handled by the handler.
-
visitVarInsn
public void visitVarInsn(int opcode, int var)override this so we can see track which local var slots are in use and avoid overwriting them- Overrides:
visitVarInsnin classorg.objectweb.asm.MethodVisitor- Parameters:
opcode- the bytecode operationvar- local variable index
-
newLocal
public int newLocal(org.objectweb.asm.Type valueType)
return a new local slot index for a local var not currently in use. this must be released using popLocal before a new frame can be notified which means that the slot should only be allocated inside a generated trigger section and should be released before the trigger end of the trigger section by calling popLocal.- Parameters:
valueType- the type of the value to be stored in the local slot- Returns:
- the index for the new slot
-
popLocal
public void popLocal(int local)
free a previously allocated local slot- Parameters:
local- the slot to be released
-
loadLocal
public void loadLocal(int local)
load a value onto the stack from a local var slot which can obtained from a call to newLocal or from a lcoal variable table entry.- Parameters:
local- the slot to load from
-
storeLocal
public void storeLocal(int local)
save a value on the stack to a local var slot- Parameters:
local- the slot to save to
-
getLocalType
public org.objectweb.asm.Type getLocalType(int local)
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals)ensure we allow enough room for any extra locals on the stack- Overrides:
visitMaxsin classorg.objectweb.asm.MethodVisitor- Parameters:
maxStack- the maximum stack depthmaxLocals- the maximum local count
-
dumpFrame
private void dumpFrame(int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)
-
dumpType
private void dumpType(java.lang.StringBuffer buffer, java.lang.Object t)
-
visitFrame
public void visitFrame(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)- Overrides:
visitFramein classorg.objectweb.asm.MethodVisitor
-
-