Package org.objectweb.asm.commons
Class AnalyzerAdapter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.objectweb.asm.commons.AnalyzerAdapter
-
public class AnalyzerAdapter extends MethodVisitor
AMethodVisitorthat keeps track of stack map frame changes betweenvisitFrame(int, int, Object[], int, Object[])calls. This adapter must be used with theClassReader.EXPAND_FRAMESoption. Each visitX instruction delegates to the next visitor in the chain, if any, and then simulates the effect of this instruction on the stack map frame, represented bylocalsandstack. The next visitor in the chain can get the state of the stack map frame before each instruction by reading the value of these fields in its visitX methods (this requires a reference to the AnalyzerAdapter that is before it in the chain). If this adapter is used with a class that does not contain stack map table attributes (i.e., pre Java 6 classes) then this adapter may not be able to compute the stack map frame for each instruction. In this case no exception is thrown but thelocalsandstackfields will be null for these instructions.- Author:
- Eric Bruneton
-
-
Field Summary
Fields Modifier and Type Field Description List<Object>localsThe local variable slots for the current execution frame.List<Object>stackThe operand stack slots for the current execution frame.Map<Object,Object>uninitializedTypesThe uninitialized types in the current execution frame.-
Fields inherited from class org.objectweb.asm.MethodVisitor
api, mv
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnalyzerAdapter(int api, String owner, int access, String name, String descriptor, MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.AnalyzerAdapter(String owner, int access, String name, String descriptor, MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisitFieldInsn(int opcode, String owner, String name, String descriptor)voidvisitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack)voidvisitIincInsn(int varIndex, int increment)voidvisitInsn(int opcode)voidvisitIntInsn(int opcode, int operand)voidvisitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)voidvisitJumpInsn(int opcode, Label label)voidvisitLabel(Label label)voidvisitLdcInsn(Object value)voidvisitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index)voidvisitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)voidvisitMaxs(int maxStack, int maxLocals)voidvisitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface)voidvisitMultiANewArrayInsn(String descriptor, int numDimensions)voidvisitTableSwitchInsn(int min, int max, Label dflt, Label... labels)voidvisitTypeInsn(int opcode, String type)voidvisitVarInsn(int opcode, int varIndex)-
Methods inherited from class org.objectweb.asm.MethodVisitor
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitInsnAnnotation, visitLineNumber, visitLocalVariableAnnotation, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation
-
-
-
-
Field Detail
-
locals
public List<Object> locals
The local variable slots for the current execution frame. Primitive types are represented byOpcodes.TOP,Opcodes.INTEGER,Opcodes.FLOAT,Opcodes.LONG,Opcodes.DOUBLE,Opcodes.NULLorOpcodes.UNINITIALIZED_THIS(long and double are represented by two elements, the second one being TOP). Reference types are represented by String objects (representing internal names), and uninitialized types by Label objects (this label designates the NEW instruction that created this uninitialized value). This field is null for unreachable instructions.
-
stack
public List<Object> stack
The operand stack slots for the current execution frame. Primitive types are represented byOpcodes.TOP,Opcodes.INTEGER,Opcodes.FLOAT,Opcodes.LONG,Opcodes.DOUBLE,Opcodes.NULLorOpcodes.UNINITIALIZED_THIS(long and double are represented by two elements, the second one being TOP). Reference types are represented by String objects (representing internal names), and uninitialized types by Label objects (this label designates the NEW instruction that created this uninitialized value). This field is null for unreachable instructions.
-
uninitializedTypes
public Map<Object,Object> uninitializedTypes
The uninitialized types in the current execution frame. This map associates internal names to Label objects. Each label designates a NEW instruction that created the currently uninitialized types, and the associated internal name represents the NEW operand, i.e. the final, initialized type value.
-
-
Constructor Detail
-
AnalyzerAdapter
public AnalyzerAdapter(String owner, int access, String name, String descriptor, MethodVisitor methodVisitor)
Constructs a newAnalyzerAdapter. Subclasses must not use this constructor. Instead, they must use theAnalyzerAdapter(int, String, int, String, String, MethodVisitor)version.- Parameters:
owner- the owner's class name.access- the method's access flags (seeOpcodes).name- the method's name.descriptor- the method's descriptor (seeType).methodVisitor- the method visitor to which this adapter delegates calls. May be null.- Throws:
IllegalStateException- If a subclass calls this constructor.
-
AnalyzerAdapter
protected AnalyzerAdapter(int api, String owner, int access, String name, String descriptor, MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.- Parameters:
api- the ASM API version implemented by this visitor. Must be one of theASMx values inOpcodes.owner- the owner's class name.access- the method's access flags (seeOpcodes).name- the method's name.descriptor- the method's descriptor (seeType).methodVisitor- the method visitor to which this adapter delegates calls. May be null.
-
-
Method Detail
-
visitFrame
public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack)- Overrides:
visitFramein classMethodVisitor
-
visitInsn
public void visitInsn(int opcode)
- Overrides:
visitInsnin classMethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)- Overrides:
visitIntInsnin classMethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int varIndex)- Overrides:
visitVarInsnin classMethodVisitor
-
visitTypeInsn
public void visitTypeInsn(int opcode, String type)- Overrides:
visitTypeInsnin classMethodVisitor
-
visitFieldInsn
public void visitFieldInsn(int opcode, String owner, String name, String descriptor)- Overrides:
visitFieldInsnin classMethodVisitor
-
visitMethodInsn
public void visitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface)- Overrides:
visitMethodInsnin classMethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
- Overrides:
visitInvokeDynamicInsnin classMethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, Label label)- Overrides:
visitJumpInsnin classMethodVisitor
-
visitLabel
public void visitLabel(Label label)
- Overrides:
visitLabelin classMethodVisitor
-
visitLdcInsn
public void visitLdcInsn(Object value)
- Overrides:
visitLdcInsnin classMethodVisitor
-
visitIincInsn
public void visitIincInsn(int varIndex, int increment)- Overrides:
visitIincInsnin classMethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels)- Overrides:
visitTableSwitchInsnin classMethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels)
- Overrides:
visitLookupSwitchInsnin classMethodVisitor
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(String descriptor, int numDimensions)
- Overrides:
visitMultiANewArrayInsnin classMethodVisitor
-
visitLocalVariable
public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index)
- Overrides:
visitLocalVariablein classMethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals)- Overrides:
visitMaxsin classMethodVisitor
-
-