Class AnalyzerAdapter

java.lang.Object
org.objectweb.asm.MethodVisitor
org.objectweb.asm.commons.AnalyzerAdapter

public class AnalyzerAdapter extends org.objectweb.asm.MethodVisitor
A MethodVisitor that keeps track of stack map frame changes between visitFrame(int, int, Object[], int, Object[]) calls. This adapter must be used with the ClassReader.EXPAND_FRAMES option. 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 by locals and stack. 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 the locals and stack fields will be null for these instructions.
  • Field Details

    • locals

      public List<Object> locals
      The local variable slots for the current execution frame. Primitive types are represented by Opcodes.TOP, Opcodes.INTEGER, Opcodes.FLOAT, Opcodes.LONG, Opcodes.DOUBLE,Opcodes.NULL or Opcodes.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, see Type.getInternalName()), 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 by Opcodes.TOP, Opcodes.INTEGER, Opcodes.FLOAT, Opcodes.LONG, Opcodes.DOUBLE,Opcodes.NULL or Opcodes.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, see Type.getInternalName()), 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 (see Type.getInternalName()). 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 Details

    • AnalyzerAdapter

      public AnalyzerAdapter(String owner, int access, String name, String descriptor, org.objectweb.asm.MethodVisitor methodVisitor)
      Constructs a new AnalyzerAdapter. Subclasses must not use this constructor. Instead, they must use the AnalyzerAdapter(int, String, int, String, String, MethodVisitor) version.
      Parameters:
      owner - the owner's class name.
      access - the method's access flags (see Opcodes).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      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, org.objectweb.asm.MethodVisitor methodVisitor)
      Constructs a new AnalyzerAdapter.
      Parameters:
      api - the ASM API version implemented by this visitor. Must be one of the ASMx values in Opcodes.
      owner - the owner's class name.
      access - the method's access flags (see Opcodes).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      methodVisitor - the method visitor to which this adapter delegates calls. May be null.
  • Method Details

    • visitFrame

      public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack)
      Overrides:
      visitFrame in class org.objectweb.asm.MethodVisitor
    • visitInsn

      public void visitInsn(int opcode)
      Overrides:
      visitInsn in class org.objectweb.asm.MethodVisitor
    • visitIntInsn

      public void visitIntInsn(int opcode, int operand)
      Overrides:
      visitIntInsn in class org.objectweb.asm.MethodVisitor
    • visitVarInsn

      public void visitVarInsn(int opcode, int varIndex)
      Overrides:
      visitVarInsn in class org.objectweb.asm.MethodVisitor
    • visitTypeInsn

      public void visitTypeInsn(int opcode, String type)
      Overrides:
      visitTypeInsn in class org.objectweb.asm.MethodVisitor
    • visitFieldInsn

      public void visitFieldInsn(int opcode, String owner, String name, String descriptor)
      Overrides:
      visitFieldInsn in class org.objectweb.asm.MethodVisitor
    • visitMethodInsn

      public void visitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface)
      Overrides:
      visitMethodInsn in class org.objectweb.asm.MethodVisitor
    • visitInvokeDynamicInsn

      public void visitInvokeDynamicInsn(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
      Overrides:
      visitInvokeDynamicInsn in class org.objectweb.asm.MethodVisitor
    • visitJumpInsn

      public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)
      Overrides:
      visitJumpInsn in class org.objectweb.asm.MethodVisitor
    • visitLabel

      public void visitLabel(org.objectweb.asm.Label label)
      Overrides:
      visitLabel in class org.objectweb.asm.MethodVisitor
    • visitLdcInsn

      public void visitLdcInsn(Object value)
      Overrides:
      visitLdcInsn in class org.objectweb.asm.MethodVisitor
    • visitIincInsn

      public void visitIincInsn(int varIndex, int increment)
      Overrides:
      visitIincInsn in class org.objectweb.asm.MethodVisitor
    • visitTableSwitchInsn

      public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
      Overrides:
      visitTableSwitchInsn in class org.objectweb.asm.MethodVisitor
    • visitLookupSwitchInsn

      public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
      Overrides:
      visitLookupSwitchInsn in class org.objectweb.asm.MethodVisitor
    • visitMultiANewArrayInsn

      public void visitMultiANewArrayInsn(String descriptor, int numDimensions)
      Overrides:
      visitMultiANewArrayInsn in class org.objectweb.asm.MethodVisitor
    • visitLocalVariable

      public void visitLocalVariable(String name, String descriptor, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)
      Overrides:
      visitLocalVariable in class org.objectweb.asm.MethodVisitor
    • visitMaxs

      public void visitMaxs(int maxStack, int maxLocals)
      Overrides:
      visitMaxs in class org.objectweb.asm.MethodVisitor