Package org.objectweb.asm.commons
Class AnalyzerAdapter
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.objectweb.asm.commons.AnalyzerAdapter
-
public class AnalyzerAdapter extends org.objectweb.asm.MethodVisitorAMethodVisitorthat 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 java.util.List<java.lang.Object>localsThe local variable slots for the current execution frame.java.util.List<java.lang.Object>stackThe operand stack slots for the current execution frame.java.util.Map<java.lang.Object,java.lang.Object>uninitializedTypesThe uninitialized types in the current execution frame.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnalyzerAdapter(int api, java.lang.String owner, int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.AnalyzerAdapter(java.lang.String owner, int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidvisitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)voidvisitFrame(int type, int numLocal, java.lang.Object[] local, int numStack, java.lang.Object[] stack)voidvisitIincInsn(int var, int increment)voidvisitInsn(int opcode)voidvisitIntInsn(int opcode, int operand)voidvisitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label)voidvisitLabel(org.objectweb.asm.Label label)voidvisitLdcInsn(java.lang.Object value)voidvisitLocalVariable(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)voidvisitMaxs(int maxStack, int maxLocals)voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)Deprecated.voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)voidvisitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)voidvisitTypeInsn(int opcode, java.lang.String type)voidvisitVarInsn(int opcode, int var)-
Methods inherited from class org.objectweb.asm.MethodVisitor
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitInsnAnnotation, visitLineNumber, visitLocalVariableAnnotation, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation
-
-
-
-
Field Detail
-
locals
public java.util.List<java.lang.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 java.util.List<java.lang.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 java.util.Map<java.lang.Object,java.lang.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(java.lang.String owner, int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.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:
java.lang.IllegalStateException- If a subclass calls this constructor.
-
AnalyzerAdapter
protected AnalyzerAdapter(int api, java.lang.String owner, int access, java.lang.String name, java.lang.String descriptor, org.objectweb.asm.MethodVisitor methodVisitor)Constructs a newAnalyzerAdapter.- Parameters:
api- the ASM API version implemented by this visitor. Must be one ofOpcodes.ASM4,Opcodes.ASM5,Opcodes.ASM6orOpcodes.ASM7.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, java.lang.Object[] local, int numStack, java.lang.Object[] stack)- Overrides:
visitFramein classorg.objectweb.asm.MethodVisitor
-
visitInsn
public void visitInsn(int opcode)
- Overrides:
visitInsnin classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)- Overrides:
visitIntInsnin classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int var)- Overrides:
visitVarInsnin classorg.objectweb.asm.MethodVisitor
-
visitTypeInsn
public void visitTypeInsn(int opcode, java.lang.String type)- Overrides:
visitTypeInsnin classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)- Overrides:
visitFieldInsnin classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
@Deprecated public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor)Deprecated.Deprecated.- Overrides:
visitMethodInsnin classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String descriptor, boolean isInterface)- Overrides:
visitMethodInsnin classorg.objectweb.asm.MethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)- Overrides:
visitInvokeDynamicInsnin classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)- Overrides:
visitJumpInsnin classorg.objectweb.asm.MethodVisitor
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label)
- Overrides:
visitLabelin classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
public void visitLdcInsn(java.lang.Object value)
- Overrides:
visitLdcInsnin classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int var, int increment)- Overrides:
visitIincInsnin classorg.objectweb.asm.MethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)- Overrides:
visitTableSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)- Overrides:
visitLookupSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(java.lang.String descriptor, int numDimensions)- Overrides:
visitMultiANewArrayInsnin classorg.objectweb.asm.MethodVisitor
-
visitLocalVariable
public void visitLocalVariable(java.lang.String name, java.lang.String descriptor, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)- Overrides:
visitLocalVariablein classorg.objectweb.asm.MethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals)- Overrides:
visitMaxsin classorg.objectweb.asm.MethodVisitor
-
-