Class InstructionAdapter

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

public class InstructionAdapter extends org.objectweb.asm.MethodVisitor
A MethodVisitor providing a more detailed API to generate and transform instructions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.objectweb.asm.Type
    The type of the java.lang.Object class.

    Fields inherited from class org.objectweb.asm.MethodVisitor

    api, mv
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    InstructionAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor)
    Constructs a new InstructionAdapter.
     
    InstructionAdapter(org.objectweb.asm.MethodVisitor methodVisitor)
    Constructs a new InstructionAdapter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    aconst(Object value)
    Generates the instruction to push the given value on the stack.
    void
    add(org.objectweb.asm.Type type)
     
    void
    aload(org.objectweb.asm.Type type)
     
    void
    and(org.objectweb.asm.Type type)
     
    void
    anew(org.objectweb.asm.Type type)
     
    void
    areturn(org.objectweb.asm.Type type)
     
    void
     
    void
    astore(org.objectweb.asm.Type type)
     
    void
     
    void
    cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
    Generates the instruction to cast from the first given type to the other.
    void
    cconst(org.objectweb.asm.ConstantDynamic constantDynamic)
    Generates the instruction to push the given constant dynamic on the stack.
    void
    checkcast(org.objectweb.asm.Type type)
     
    void
    cmpg(org.objectweb.asm.Type type)
     
    void
    cmpl(org.objectweb.asm.Type type)
     
    void
    dconst(double doubleValue)
    Generates the instruction to push the given value on the stack.
    void
    div(org.objectweb.asm.Type type)
     
    void
    dup()
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
    fconst(float floatValue)
    Generates the instruction to push the given value on the stack.
    void
    getfield(String owner, String name, String descriptor)
     
    void
    getstatic(String owner, String name, String descriptor)
     
    void
    goTo(org.objectweb.asm.Label label)
     
    void
    hconst(org.objectweb.asm.Handle handle)
    Generates the instruction to push the given handle on the stack.
    void
    iconst(int intValue)
    Generates the instruction to push the given value on the stack.
    void
    ifacmpeq(org.objectweb.asm.Label label)
     
    void
    ifacmpne(org.objectweb.asm.Label label)
     
    void
    ifeq(org.objectweb.asm.Label label)
     
    void
    ifge(org.objectweb.asm.Label label)
     
    void
    ifgt(org.objectweb.asm.Label label)
     
    void
    ificmpeq(org.objectweb.asm.Label label)
     
    void
    ificmpge(org.objectweb.asm.Label label)
     
    void
    ificmpgt(org.objectweb.asm.Label label)
     
    void
    ificmple(org.objectweb.asm.Label label)
     
    void
    ificmplt(org.objectweb.asm.Label label)
     
    void
    ificmpne(org.objectweb.asm.Label label)
     
    void
    ifle(org.objectweb.asm.Label label)
     
    void
    iflt(org.objectweb.asm.Label label)
     
    void
    ifne(org.objectweb.asm.Label label)
     
    void
    ifnonnull(org.objectweb.asm.Label label)
     
    void
    ifnull(org.objectweb.asm.Label label)
     
    void
    iinc(int varIndex, int increment)
     
    void
    instanceOf(org.objectweb.asm.Type type)
     
    void
    invokedynamic(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object[] bootstrapMethodArguments)
    Generates the instruction to call the given dynamic method.
    void
    invokeinterface(String owner, String name, String descriptor)
    Generates the instruction to call the given interface method.
    void
    invokespecial(String owner, String name, String descriptor)
    void
    invokespecial(String owner, String name, String descriptor, boolean isInterface)
    Generates the instruction to call the given special method.
    void
    invokestatic(String owner, String name, String descriptor)
    void
    invokestatic(String owner, String name, String descriptor, boolean isInterface)
    Generates the instruction to call the given static method.
    void
    invokevirtual(String owner, String name, String descriptor)
    void
    invokevirtual(String owner, String name, String descriptor, boolean isInterface)
    Generates the instruction to call the given virtual method.
    void
    jsr(org.objectweb.asm.Label label)
     
    void
     
    void
    lconst(long longValue)
    Generates the instruction to push the given value on the stack.
    void
    load(int varIndex, org.objectweb.asm.Type type)
     
    void
    lookupswitch(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
     
    void
    mark(org.objectweb.asm.Label label)
     
    void
     
    void
     
    void
    mul(org.objectweb.asm.Type type)
     
    void
    multianewarray(String descriptor, int numDimensions)
     
    void
    neg(org.objectweb.asm.Type type)
     
    void
    newarray(org.objectweb.asm.Type type)
    Generates the instruction to create and push on the stack an array of the given type.
    void
    nop()
    Generates a nop instruction.
    void
    or(org.objectweb.asm.Type type)
     
    void
    pop()
     
    void
     
    void
    putfield(String owner, String name, String descriptor)
     
    void
    putstatic(String owner, String name, String descriptor)
     
    void
    rem(org.objectweb.asm.Type type)
     
    void
    ret(int varIndex)
     
    void
    shl(org.objectweb.asm.Type type)
     
    void
    shr(org.objectweb.asm.Type type)
     
    void
    store(int varIndex, org.objectweb.asm.Type type)
     
    void
    sub(org.objectweb.asm.Type type)
     
    void
     
    void
    tableswitch(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
     
    void
    tconst(org.objectweb.asm.Type type)
    Generates the instruction to push the given type on the stack.
    void
    ushr(org.objectweb.asm.Type type)
     
    void
    visitFieldInsn(int opcode, String owner, String name, String descriptor)
     
    void
    visitIincInsn(int varIndex, int increment)
     
    void
    visitInsn(int opcode)
     
    void
    visitIntInsn(int opcode, int operand)
     
    void
    visitInvokeDynamicInsn(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
     
    void
    visitJumpInsn(int opcode, org.objectweb.asm.Label label)
     
    void
    visitLabel(org.objectweb.asm.Label label)
     
    void
     
    void
    visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
     
    void
    visitMethodInsn(int opcodeAndSource, String owner, String name, String descriptor, boolean isInterface)
     
    void
    visitMultiANewArrayInsn(String descriptor, int numDimensions)
     
    void
    visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
     
    void
    visitTypeInsn(int opcode, String type)
     
    void
    visitVarInsn(int opcode, int varIndex)
     
    void
    xor(org.objectweb.asm.Type type)
     

    Methods inherited from class org.objectweb.asm.MethodVisitor

    getDelegate, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFrame, visitInsnAnnotation, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OBJECT_TYPE

      public static final org.objectweb.asm.Type OBJECT_TYPE
      The type of the java.lang.Object class.
  • Constructor Details

    • InstructionAdapter

      public InstructionAdapter(org.objectweb.asm.MethodVisitor methodVisitor)
      Constructs a new InstructionAdapter. Subclasses must not use this constructor. Instead, they must use the InstructionAdapter(int, MethodVisitor) version.
      Parameters:
      methodVisitor - the method visitor to which this adapter delegates calls.
      Throws:
      IllegalStateException - If a subclass calls this constructor.
    • InstructionAdapter

      protected InstructionAdapter(int api, org.objectweb.asm.MethodVisitor methodVisitor)
      Constructs a new InstructionAdapter.
      Parameters:
      api - the ASM API version implemented by this visitor. Must be one of the ASMx values in Opcodes.
      methodVisitor - the method visitor to which this adapter delegates calls.
  • Method Details

    • 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
    • nop

      public void nop()
      Generates a nop instruction.
    • aconst

      public void aconst(Object value)
      Generates the instruction to push the given value on the stack.
      Parameters:
      value - the constant to be pushed on the stack. This parameter must be an Integer, a Float, a Long, a Double, a String, a Type of OBJECT or ARRAY sort for .class constants, for classes whose version is 49, a Type of METHOD sort for MethodType, a Handle for MethodHandle constants, for classes whose version is 51 or a ConstantDynamic for a constant dynamic for classes whose version is 55.
    • iconst

      public void iconst(int intValue)
      Generates the instruction to push the given value on the stack.
      Parameters:
      intValue - the constant to be pushed on the stack.
    • lconst

      public void lconst(long longValue)
      Generates the instruction to push the given value on the stack.
      Parameters:
      longValue - the constant to be pushed on the stack.
    • fconst

      public void fconst(float floatValue)
      Generates the instruction to push the given value on the stack.
      Parameters:
      floatValue - the constant to be pushed on the stack.
    • dconst

      public void dconst(double doubleValue)
      Generates the instruction to push the given value on the stack.
      Parameters:
      doubleValue - the constant to be pushed on the stack.
    • tconst

      public void tconst(org.objectweb.asm.Type type)
      Generates the instruction to push the given type on the stack.
      Parameters:
      type - the type to be pushed on the stack.
    • hconst

      public void hconst(org.objectweb.asm.Handle handle)
      Generates the instruction to push the given handle on the stack.
      Parameters:
      handle - the handle to be pushed on the stack.
    • cconst

      public void cconst(org.objectweb.asm.ConstantDynamic constantDynamic)
      Generates the instruction to push the given constant dynamic on the stack.
      Parameters:
      constantDynamic - the constant dynamic to be pushed on the stack.
    • load

      public void load(int varIndex, org.objectweb.asm.Type type)
    • aload

      public void aload(org.objectweb.asm.Type type)
    • store

      public void store(int varIndex, org.objectweb.asm.Type type)
    • astore

      public void astore(org.objectweb.asm.Type type)
    • pop

      public void pop()
    • pop2

      public void pop2()
    • dup

      public void dup()
    • dup2

      public void dup2()
    • dupX1

      public void dupX1()
    • dupX2

      public void dupX2()
    • dup2X1

      public void dup2X1()
    • dup2X2

      public void dup2X2()
    • swap

      public void swap()
    • add

      public void add(org.objectweb.asm.Type type)
    • sub

      public void sub(org.objectweb.asm.Type type)
    • mul

      public void mul(org.objectweb.asm.Type type)
    • div

      public void div(org.objectweb.asm.Type type)
    • rem

      public void rem(org.objectweb.asm.Type type)
    • neg

      public void neg(org.objectweb.asm.Type type)
    • shl

      public void shl(org.objectweb.asm.Type type)
    • shr

      public void shr(org.objectweb.asm.Type type)
    • ushr

      public void ushr(org.objectweb.asm.Type type)
    • and

      public void and(org.objectweb.asm.Type type)
    • or

      public void or(org.objectweb.asm.Type type)
    • xor

      public void xor(org.objectweb.asm.Type type)
    • iinc

      public void iinc(int varIndex, int increment)
    • cast

      public void cast(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
      Generates the instruction to cast from the first given type to the other.
      Parameters:
      from - a Type.
      to - a Type.
    • lcmp

      public void lcmp()
    • cmpl

      public void cmpl(org.objectweb.asm.Type type)
    • cmpg

      public void cmpg(org.objectweb.asm.Type type)
    • ifeq

      public void ifeq(org.objectweb.asm.Label label)
    • ifne

      public void ifne(org.objectweb.asm.Label label)
    • iflt

      public void iflt(org.objectweb.asm.Label label)
    • ifge

      public void ifge(org.objectweb.asm.Label label)
    • ifgt

      public void ifgt(org.objectweb.asm.Label label)
    • ifle

      public void ifle(org.objectweb.asm.Label label)
    • ificmpeq

      public void ificmpeq(org.objectweb.asm.Label label)
    • ificmpne

      public void ificmpne(org.objectweb.asm.Label label)
    • ificmplt

      public void ificmplt(org.objectweb.asm.Label label)
    • ificmpge

      public void ificmpge(org.objectweb.asm.Label label)
    • ificmpgt

      public void ificmpgt(org.objectweb.asm.Label label)
    • ificmple

      public void ificmple(org.objectweb.asm.Label label)
    • ifacmpeq

      public void ifacmpeq(org.objectweb.asm.Label label)
    • ifacmpne

      public void ifacmpne(org.objectweb.asm.Label label)
    • goTo

      public void goTo(org.objectweb.asm.Label label)
    • jsr

      public void jsr(org.objectweb.asm.Label label)
    • ret

      public void ret(int varIndex)
    • tableswitch

      public void tableswitch(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)
    • lookupswitch

      public void lookupswitch(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
    • areturn

      public void areturn(org.objectweb.asm.Type type)
    • getstatic

      public void getstatic(String owner, String name, String descriptor)
    • putstatic

      public void putstatic(String owner, String name, String descriptor)
    • getfield

      public void getfield(String owner, String name, String descriptor)
    • putfield

      public void putfield(String owner, String name, String descriptor)
    • invokevirtual

      @Deprecated public void invokevirtual(String owner, String name, String descriptor)
      Deprecated.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
    • invokevirtual

      public void invokevirtual(String owner, String name, String descriptor, boolean isInterface)
      Generates the instruction to call the given virtual method.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      isInterface - if the method's owner class is an interface.
    • invokespecial

      @Deprecated public void invokespecial(String owner, String name, String descriptor)
      Deprecated.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
    • invokespecial

      public void invokespecial(String owner, String name, String descriptor, boolean isInterface)
      Generates the instruction to call the given special method.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      isInterface - if the method's owner class is an interface.
    • invokestatic

      @Deprecated public void invokestatic(String owner, String name, String descriptor)
      Deprecated.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
    • invokestatic

      public void invokestatic(String owner, String name, String descriptor, boolean isInterface)
      Generates the instruction to call the given static method.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      isInterface - if the method's owner class is an interface.
    • invokeinterface

      public void invokeinterface(String owner, String name, String descriptor)
      Generates the instruction to call the given interface method.
      Parameters:
      owner - the internal name of the method's owner class (see Type.getInternalName()).
      name - the method's name.
      descriptor - the method's descriptor (see Type).
    • invokedynamic

      public void invokedynamic(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object[] bootstrapMethodArguments)
      Generates the instruction to call the given dynamic method.
      Parameters:
      name - the method's name.
      descriptor - the method's descriptor (see Type).
      bootstrapMethodHandle - the bootstrap method.
      bootstrapMethodArguments - the bootstrap method constant arguments. Each argument must be an Integer, Float, Long, Double, String, Type, Handle or ConstantDynamic value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
    • anew

      public void anew(org.objectweb.asm.Type type)
    • newarray

      public void newarray(org.objectweb.asm.Type type)
      Generates the instruction to create and push on the stack an array of the given type.
      Parameters:
      type - an array Type.
    • arraylength

      public void arraylength()
    • athrow

      public void athrow()
    • checkcast

      public void checkcast(org.objectweb.asm.Type type)
    • instanceOf

      public void instanceOf(org.objectweb.asm.Type type)
    • monitorenter

      public void monitorenter()
    • monitorexit

      public void monitorexit()
    • multianewarray

      public void multianewarray(String descriptor, int numDimensions)
    • ifnull

      public void ifnull(org.objectweb.asm.Label label)
    • ifnonnull

      public void ifnonnull(org.objectweb.asm.Label label)
    • mark

      public void mark(org.objectweb.asm.Label label)