public class StackAwareMethodVisitor
extends org.objectweb.asm.MethodVisitor
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<StackSize> |
current
A list of the current elements on the operand stack.
|
private int |
freeIndex
The next index of the local variable array that is available.
|
private static int[] |
SIZE_CHANGE
An array mapping any opcode to its size impact onto the operand stack.
|
private java.util.Map<org.objectweb.asm.Label,java.util.List<StackSize>> |
sizes
A mapping of labels to the operand stack size that is expected at this label.
|
| Constructor and Description |
|---|
StackAwareMethodVisitor(org.objectweb.asm.MethodVisitor methodVisitor,
MethodDescription instrumentedMethod)
Creates a new stack aware method visitor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
adjustStack(int delta)
Adjusts the current state of the operand stack.
|
private void |
adjustStack(int delta,
int offset)
Adjusts the current state of the operand stack.
|
private void |
doDrain(java.util.List<StackSize> stackSizes)
Drains all supplied elements of the operand stack.
|
void |
drainStack()
Pops all values currently on the stack.
|
int |
drainStack(int store,
int load,
StackSize size)
Drains the stack to only contain the top value.
|
void |
register(org.objectweb.asm.Label label,
java.util.List<StackSize> stackSizes)
Explicitly registers a label to define a given stack state.
|
void |
visitFieldInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor) |
void |
visitInsn(int opcode) |
void |
visitIntInsn(int opcode,
int operand) |
void |
visitInvokeDynamicInsn(java.lang.String name,
java.lang.String descriptor,
org.objectweb.asm.Handle bootstrap,
java.lang.Object... bootstrapArguments) |
void |
visitJumpInsn(int opcode,
org.objectweb.asm.Label label) |
void |
visitLabel(org.objectweb.asm.Label label) |
void |
visitLdcInsn(java.lang.Object value) |
void |
visitLineNumber(int line,
org.objectweb.asm.Label start) |
void |
visitLookupSwitchInsn(org.objectweb.asm.Label defaultOption,
int[] key,
org.objectweb.asm.Label[] option) |
void |
visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface) |
void |
visitMultiANewArrayInsn(java.lang.String descriptor,
int dimension) |
void |
visitTableSwitchInsn(int minimum,
int maximum,
org.objectweb.asm.Label defaultOption,
org.objectweb.asm.Label... option) |
void |
visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
java.lang.String type) |
void |
visitTypeInsn(int opcode,
java.lang.String type) |
void |
visitVarInsn(int opcode,
int variable) |
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFrame, visitIincInsn, visitInsnAnnotation, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTypeAnnotationprivate static final int[] SIZE_CHANGE
Frame with the difference that the Opcodes.JSR instruction is
mapped to a size of 0 as it does not impact the stack after returning from the instruction.private java.util.List<StackSize> current
private final java.util.Map<org.objectweb.asm.Label,java.util.List<StackSize>> sizes
private int freeIndex
public StackAwareMethodVisitor(org.objectweb.asm.MethodVisitor methodVisitor,
MethodDescription instrumentedMethod)
methodVisitor - The method visitor to delegate operations to.instrumentedMethod - The method description for which this method visitor is applied.private void adjustStack(int delta)
delta - The change of the current operation of the operand stack. Must not be larger than 2.private void adjustStack(int delta,
int offset)
delta - The change of the current operation of the operand stack. Must not be larger than 2.offset - The offset of the value within the operand stack. Must be bigger then 0 and smaller than
the current stack size. Only permitted if the supplied delta is positive.public void drainStack()
public int drainStack(int store,
int load,
StackSize size)
store - The opcode used for storing the top value.load - The opcode used for loading the top value.size - The size of the value on top of the operand stack.private void doDrain(java.util.List<StackSize> stackSizes)
stackSizes - The stack sizes of the elements to drain.public void register(org.objectweb.asm.Label label,
java.util.List<StackSize> stackSizes)
label - The label to register a stack state for.stackSizes - The stack sizes to assume when reaching the supplied label.public void visitInsn(int opcode)
visitInsn in class org.objectweb.asm.MethodVisitorpublic void visitIntInsn(int opcode,
int operand)
visitIntInsn in class org.objectweb.asm.MethodVisitorpublic void visitVarInsn(int opcode,
int variable)
visitVarInsn in class org.objectweb.asm.MethodVisitorpublic void visitTypeInsn(int opcode,
java.lang.String type)
visitTypeInsn in class org.objectweb.asm.MethodVisitorpublic void visitFieldInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor)
visitFieldInsn in class org.objectweb.asm.MethodVisitorpublic void visitMethodInsn(int opcode,
java.lang.String owner,
java.lang.String name,
java.lang.String descriptor,
boolean isInterface)
visitMethodInsn in class org.objectweb.asm.MethodVisitorpublic void visitInvokeDynamicInsn(java.lang.String name,
java.lang.String descriptor,
org.objectweb.asm.Handle bootstrap,
java.lang.Object... bootstrapArguments)
visitInvokeDynamicInsn in class org.objectweb.asm.MethodVisitorpublic void visitLdcInsn(java.lang.Object value)
visitLdcInsn in class org.objectweb.asm.MethodVisitorpublic void visitMultiANewArrayInsn(java.lang.String descriptor,
int dimension)
visitMultiANewArrayInsn in class org.objectweb.asm.MethodVisitorpublic void visitJumpInsn(int opcode,
org.objectweb.asm.Label label)
visitJumpInsn in class org.objectweb.asm.MethodVisitorpublic void visitLabel(org.objectweb.asm.Label label)
visitLabel in class org.objectweb.asm.MethodVisitorpublic void visitLineNumber(int line,
org.objectweb.asm.Label start)
visitLineNumber in class org.objectweb.asm.MethodVisitorpublic void visitTableSwitchInsn(int minimum,
int maximum,
org.objectweb.asm.Label defaultOption,
org.objectweb.asm.Label... option)
visitTableSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitLookupSwitchInsn(org.objectweb.asm.Label defaultOption,
int[] key,
org.objectweb.asm.Label[] option)
visitLookupSwitchInsn in class org.objectweb.asm.MethodVisitorpublic void visitTryCatchBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label handler,
java.lang.String type)
visitTryCatchBlock in class org.objectweb.asm.MethodVisitor