Class GeneratorAdapter

  • Direct Known Subclasses:
    AdviceAdapter

    public class GeneratorAdapter
    extends LocalVariablesSorter
    A MethodVisitor with convenient methods to generate code. For example, using this adapter, the class below
     public class Example {
       public static void main(String[] args) {
         System.out.println("Hello world!");
       }
     }
     

    can be generated as follows:

     ClassWriter cw = new ClassWriter(0);
     cw.visit(V1_1, ACC_PUBLIC, "Example", null, "java/lang/Object", null);
    
     Method m = Method.getMethod("void <init> ()");
     GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);
     mg.loadThis();
     mg.invokeConstructor(Type.getType(Object.class), m);
     mg.returnValue();
     mg.endMethod();
    
     m = Method.getMethod("void main (String[])");
     mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);
     mg.getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
     mg.push("Hello world!");
     mg.invokeVirtual(Type.getType(PrintStream.class),
             Method.getMethod("void println (String)"));
     mg.returnValue();
     mg.endMethod();
    
     cw.visitEnd();
     
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        GeneratorAdapter​(int access, Method method, java.lang.String signature, org.objectweb.asm.Type[] exceptions, org.objectweb.asm.ClassVisitor classVisitor)
      Constructs a new GeneratorAdapter.
        GeneratorAdapter​(int access, Method method, org.objectweb.asm.MethodVisitor methodVisitor)
      Constructs a new GeneratorAdapter.
      protected GeneratorAdapter​(int api, org.objectweb.asm.MethodVisitor methodVisitor, int access, java.lang.String name, java.lang.String descriptor)
      Constructs a new GeneratorAdapter.
        GeneratorAdapter​(org.objectweb.asm.MethodVisitor methodVisitor, int access, java.lang.String name, java.lang.String descriptor)
      Constructs a new GeneratorAdapter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void arrayLength()
      Generates the instruction to compute the length of an array.
      void arrayLoad​(org.objectweb.asm.Type type)
      Generates the instruction to load an element from an array.
      void arrayStore​(org.objectweb.asm.Type type)
      Generates the instruction to store an element in an array.
      void box​(org.objectweb.asm.Type type)
      Generates the instructions to box the top stack value.
      void cast​(org.objectweb.asm.Type from, org.objectweb.asm.Type to)
      Generates the instructions to cast a numerical value from one type to another.
      void catchException​(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Type exception)
      Marks the start of an exception handler.
      void checkCast​(org.objectweb.asm.Type type)
      Generates the instruction to check that the top stack value is of the given type.
      void dup()
      Generates a DUP instruction.
      void dup2()
      Generates a DUP2 instruction.
      void dup2X1()
      Generates a DUP2_X1 instruction.
      void dup2X2()
      Generates a DUP2_X2 instruction.
      void dupX1()
      Generates a DUP_X1 instruction.
      void dupX2()
      Generates a DUP_X2 instruction.
      void endMethod()
      Marks the end of the visited method.
      int getAccess()  
      org.objectweb.asm.Type[] getArgumentTypes()  
      void getField​(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)
      Generates the instruction to push the value of a non static field on the stack.
      org.objectweb.asm.Type getLocalType​(int local)
      Returns the type of the given local variable.
      java.lang.String getName()  
      org.objectweb.asm.Type getReturnType()  
      void getStatic​(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)
      Generates the instruction to push the value of a static field on the stack.
      void goTo​(org.objectweb.asm.Label label)
      Generates the instruction to jump to the given label.
      void ifCmp​(org.objectweb.asm.Type type, int mode, org.objectweb.asm.Label label)
      Generates the instructions to jump to a label based on the comparison of the top two stack values.
      void ifICmp​(int mode, org.objectweb.asm.Label label)
      Generates the instructions to jump to a label based on the comparison of the top two integer stack values.
      void ifNonNull​(org.objectweb.asm.Label label)
      Generates the instruction to jump to the given label if the top stack value is not null.
      void ifNull​(org.objectweb.asm.Label label)
      Generates the instruction to jump to the given label if the top stack value is null.
      void ifZCmp​(int mode, org.objectweb.asm.Label label)
      Generates the instructions to jump to a label based on the comparison of the top integer stack value with zero.
      void iinc​(int local, int amount)
      Generates the instruction to increment the given local variable.
      void instanceOf​(org.objectweb.asm.Type type)
      Generates the instruction to test if the top stack value is of the given type.
      void invokeConstructor​(org.objectweb.asm.Type type, Method method)
      Generates the instruction to invoke a constructor.
      void invokeDynamic​(java.lang.String name, java.lang.String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, java.lang.Object... bootstrapMethodArguments)
      Generates an invokedynamic instruction.
      void invokeInterface​(org.objectweb.asm.Type owner, Method method)
      Generates the instruction to invoke an interface method.
      void invokeStatic​(org.objectweb.asm.Type owner, Method method)
      Generates the instruction to invoke a static method.
      void invokeVirtual​(org.objectweb.asm.Type owner, Method method)
      Generates the instruction to invoke a normal method.
      void loadArg​(int arg)
      Generates the instruction to load the given method argument on the stack.
      void loadArgArray()
      Generates the instructions to load all the method arguments on the stack, as a single object array.
      void loadArgs()
      Generates the instructions to load all the method arguments on the stack.
      void loadArgs​(int arg, int count)
      Generates the instructions to load the given method arguments on the stack.
      void loadLocal​(int local)
      Generates the instruction to load the given local variable on the stack.
      void loadLocal​(int local, org.objectweb.asm.Type type)
      Generates the instruction to load the given local variable on the stack.
      void loadThis()
      Generates the instruction to load 'this' on the stack.
      org.objectweb.asm.Label mark()
      Marks the current code position with a new label.
      void mark​(org.objectweb.asm.Label label)
      Marks the current code position with the given label.
      void math​(int op, org.objectweb.asm.Type type)
      Generates the instruction to do the specified mathematical or logical operation.
      void monitorEnter()
      Generates the instruction to get the monitor of the top stack value.
      void monitorExit()
      Generates the instruction to release the monitor of the top stack value.
      void newArray​(org.objectweb.asm.Type type)
      Generates the instruction to create a new array.
      void newInstance​(org.objectweb.asm.Type type)
      Generates the instruction to create a new object.
      org.objectweb.asm.Label newLabel()
      Constructs a new Label.
      void not()
      Generates the instructions to compute the bitwise negation of the top stack value.
      void pop()
      Generates a POP instruction.
      void pop2()
      Generates a POP2 instruction.
      void push​(boolean value)
      Generates the instruction to push the given value on the stack.
      void push​(double value)
      Generates the instruction to push the given value on the stack.
      void push​(float value)
      Generates the instruction to push the given value on the stack.
      void push​(int value)
      Generates the instruction to push the given value on the stack.
      void push​(long value)
      Generates the instruction to push the given value on the stack.
      void push​(java.lang.String value)
      Generates the instruction to push the given value on the stack.
      void push​(org.objectweb.asm.ConstantDynamic constantDynamic)
      Generates the instruction to push a constant dynamic on the stack.
      void push​(org.objectweb.asm.Handle handle)
      Generates the instruction to push a handle on the stack.
      void push​(org.objectweb.asm.Type value)
      Generates the instruction to push the given value on the stack.
      void putField​(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)
      Generates the instruction to store the top stack value in a non static field.
      void putStatic​(org.objectweb.asm.Type owner, java.lang.String name, org.objectweb.asm.Type type)
      Generates the instruction to store the top stack value in a static field.
      void ret​(int local)
      Generates a RET instruction.
      void returnValue()
      Generates the instruction to return the top stack value to the caller.
      protected void setLocalType​(int local, org.objectweb.asm.Type type)
      Notifies subclasses that a local variable has been added or remapped.
      void storeArg​(int arg)
      Generates the instruction to store the top stack value in the given method argument.
      void storeLocal​(int local)
      Generates the instruction to store the top stack value in the given local variable.
      void storeLocal​(int local, org.objectweb.asm.Type type)
      Generates the instruction to store the top stack value in the given local variable.
      void swap()
      Generates a SWAP instruction.
      void swap​(org.objectweb.asm.Type prev, org.objectweb.asm.Type type)
      Generates the instructions to swap the top two stack values.
      void tableSwitch​(int[] keys, TableSwitchGenerator generator)
      Generates the instructions for a switch statement.
      void tableSwitch​(int[] keys, TableSwitchGenerator generator, boolean useTable)
      Generates the instructions for a switch statement.
      void throwException()
      Generates the instruction to throw an exception.
      void throwException​(org.objectweb.asm.Type type, java.lang.String message)
      Generates the instructions to create and throw an exception.
      void unbox​(org.objectweb.asm.Type type)
      Generates the instructions to unbox the top stack value.
      void valueOf​(org.objectweb.asm.Type type)
      Generates the instructions to box the top stack value using Java 5's valueOf() method.
      • Methods inherited from class org.objectweb.asm.MethodVisitor

        visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeneratorAdapter

        public GeneratorAdapter​(org.objectweb.asm.MethodVisitor methodVisitor,
                                int access,
                                java.lang.String name,
                                java.lang.String descriptor)
        Constructs a new GeneratorAdapter. Subclasses must not use this constructor. Instead, they must use the GeneratorAdapter(int, MethodVisitor, int, String, String) version.
        Parameters:
        methodVisitor - the method visitor to which this adapter delegates calls.
        access - the method's access flags (see Opcodes).
        name - the method's name.
        descriptor - the method's descriptor (see Type).
        Throws:
        java.lang.IllegalStateException - if a subclass calls this constructor.
      • GeneratorAdapter

        protected GeneratorAdapter​(int api,
                                   org.objectweb.asm.MethodVisitor methodVisitor,
                                   int access,
                                   java.lang.String name,
                                   java.lang.String descriptor)
        Constructs a new GeneratorAdapter.
        Parameters:
        api - the ASM API version implemented by this visitor. Must be one of Opcodes.ASM4, Opcodes.ASM5, Opcodes.ASM6, Opcodes.ASM7, Opcodes.ASM8 or Opcodes.ASM9.
        methodVisitor - the method visitor to which this adapter delegates calls.
        access - the method's access flags (see Opcodes).
        name - the method's name.
        descriptor - the method's descriptor (see Type).
      • GeneratorAdapter

        public GeneratorAdapter​(int access,
                                Method method,
                                org.objectweb.asm.MethodVisitor methodVisitor)
        Constructs a new GeneratorAdapter. Subclasses must not use this constructor. Instead, they must use the GeneratorAdapter(int, MethodVisitor, int, String, String) version.
        Parameters:
        access - access flags of the adapted method.
        method - the adapted method.
        methodVisitor - the method visitor to which this adapter delegates calls.
      • GeneratorAdapter

        public GeneratorAdapter​(int access,
                                Method method,
                                java.lang.String signature,
                                org.objectweb.asm.Type[] exceptions,
                                org.objectweb.asm.ClassVisitor classVisitor)
        Constructs a new GeneratorAdapter. Subclasses must not use this constructor. Instead, they must use the GeneratorAdapter(int, MethodVisitor, int, String, String) version.
        Parameters:
        access - access flags of the adapted method.
        method - the adapted method.
        signature - the signature of the adapted method (may be null).
        exceptions - the exceptions thrown by the adapted method (may be null).
        classVisitor - the class visitor to which this adapter delegates calls.
    • Method Detail

      • getAccess

        public int getAccess()
      • getName

        public java.lang.String getName()
      • getReturnType

        public org.objectweb.asm.Type getReturnType()
      • getArgumentTypes

        public org.objectweb.asm.Type[] getArgumentTypes()
      • push

        public void push​(boolean value)
        Generates the instruction to push the given value on the stack.
        Parameters:
        value - the value to be pushed on the stack.
      • push

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

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

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

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

        public void push​(java.lang.String value)
        Generates the instruction to push the given value on the stack.
        Parameters:
        value - the value to be pushed on the stack. May be null.
      • push

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

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

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

        public void loadThis()
        Generates the instruction to load 'this' on the stack.
      • loadArg

        public void loadArg​(int arg)
        Generates the instruction to load the given method argument on the stack.
        Parameters:
        arg - the index of a method argument.
      • loadArgs

        public void loadArgs​(int arg,
                             int count)
        Generates the instructions to load the given method arguments on the stack.
        Parameters:
        arg - the index of the first method argument to be loaded.
        count - the number of method arguments to be loaded.
      • loadArgs

        public void loadArgs()
        Generates the instructions to load all the method arguments on the stack.
      • loadArgArray

        public void loadArgArray()
        Generates the instructions to load all the method arguments on the stack, as a single object array.
      • storeArg

        public void storeArg​(int arg)
        Generates the instruction to store the top stack value in the given method argument.
        Parameters:
        arg - the index of a method argument.
      • getLocalType

        public org.objectweb.asm.Type getLocalType​(int local)
        Returns the type of the given local variable.
        Parameters:
        local - a local variable identifier, as returned by LocalVariablesSorter.newLocal(Type).
        Returns:
        the type of the given local variable.
      • loadLocal

        public void loadLocal​(int local)
        Generates the instruction to load the given local variable on the stack.
        Parameters:
        local - a local variable identifier, as returned by LocalVariablesSorter.newLocal(Type).
      • loadLocal

        public void loadLocal​(int local,
                              org.objectweb.asm.Type type)
        Generates the instruction to load the given local variable on the stack.
        Parameters:
        local - a local variable identifier, as returned by LocalVariablesSorter.newLocal(Type).
        type - the type of this local variable.
      • storeLocal

        public void storeLocal​(int local)
        Generates the instruction to store the top stack value in the given local variable.
        Parameters:
        local - a local variable identifier, as returned by LocalVariablesSorter.newLocal(Type).
      • storeLocal

        public void storeLocal​(int local,
                               org.objectweb.asm.Type type)
        Generates the instruction to store the top stack value in the given local variable.
        Parameters:
        local - a local variable identifier, as returned by LocalVariablesSorter.newLocal(Type).
        type - the type of this local variable.
      • arrayLoad

        public void arrayLoad​(org.objectweb.asm.Type type)
        Generates the instruction to load an element from an array.
        Parameters:
        type - the type of the array element to be loaded.
      • arrayStore

        public void arrayStore​(org.objectweb.asm.Type type)
        Generates the instruction to store an element in an array.
        Parameters:
        type - the type of the array element to be stored.
      • pop

        public void pop()
        Generates a POP instruction.
      • pop2

        public void pop2()
        Generates a POP2 instruction.
      • dup

        public void dup()
        Generates a DUP instruction.
      • dup2

        public void dup2()
        Generates a DUP2 instruction.
      • dupX1

        public void dupX1()
        Generates a DUP_X1 instruction.
      • dupX2

        public void dupX2()
        Generates a DUP_X2 instruction.
      • dup2X1

        public void dup2X1()
        Generates a DUP2_X1 instruction.
      • dup2X2

        public void dup2X2()
        Generates a DUP2_X2 instruction.
      • swap

        public void swap()
        Generates a SWAP instruction.
      • swap

        public void swap​(org.objectweb.asm.Type prev,
                         org.objectweb.asm.Type type)
        Generates the instructions to swap the top two stack values.
        Parameters:
        prev - type of the top - 1 stack value.
        type - type of the top stack value.
      • math

        public void math​(int op,
                         org.objectweb.asm.Type type)
        Generates the instruction to do the specified mathematical or logical operation.
        Parameters:
        op - a mathematical or logical operation. Must be one of ADD, SUB, MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR.
        type - the type of the operand(s) for this operation.
      • not

        public void not()
        Generates the instructions to compute the bitwise negation of the top stack value.
      • iinc

        public void iinc​(int local,
                         int amount)
        Generates the instruction to increment the given local variable.
        Parameters:
        local - the local variable to be incremented.
        amount - the amount by which the local variable must be incremented.
      • cast

        public void cast​(org.objectweb.asm.Type from,
                         org.objectweb.asm.Type to)
        Generates the instructions to cast a numerical value from one type to another.
        Parameters:
        from - the type of the top stack value
        to - the type into which this value must be cast.
      • box

        public void box​(org.objectweb.asm.Type type)
        Generates the instructions to box the top stack value. This value is replaced by its boxed equivalent on top of the stack.
        Parameters:
        type - the type of the top stack value.
      • valueOf

        public void valueOf​(org.objectweb.asm.Type type)
        Generates the instructions to box the top stack value using Java 5's valueOf() method. This value is replaced by its boxed equivalent on top of the stack.
        Parameters:
        type - the type of the top stack value.
      • unbox

        public void unbox​(org.objectweb.asm.Type type)
        Generates the instructions to unbox the top stack value. This value is replaced by its unboxed equivalent on top of the stack.
        Parameters:
        type - the type of the top stack value.
      • newLabel

        public org.objectweb.asm.Label newLabel()
        Constructs a new Label.
        Returns:
        a new Label.
      • mark

        public void mark​(org.objectweb.asm.Label label)
        Marks the current code position with the given label.
        Parameters:
        label - a label.
      • mark

        public org.objectweb.asm.Label mark()
        Marks the current code position with a new label.
        Returns:
        the label that was created to mark the current code position.
      • ifCmp

        public void ifCmp​(org.objectweb.asm.Type type,
                          int mode,
                          org.objectweb.asm.Label label)
        Generates the instructions to jump to a label based on the comparison of the top two stack values.
        Parameters:
        type - the type of the top two stack values.
        mode - how these values must be compared. One of EQ, NE, LT, GE, GT, LE.
        label - where to jump if the comparison result is true.
      • ifICmp

        public void ifICmp​(int mode,
                           org.objectweb.asm.Label label)
        Generates the instructions to jump to a label based on the comparison of the top two integer stack values.
        Parameters:
        mode - how these values must be compared. One of EQ, NE, LT, GE, GT, LE.
        label - where to jump if the comparison result is true.
      • ifZCmp

        public void ifZCmp​(int mode,
                           org.objectweb.asm.Label label)
        Generates the instructions to jump to a label based on the comparison of the top integer stack value with zero.
        Parameters:
        mode - how these values must be compared. One of EQ, NE, LT, GE, GT, LE.
        label - where to jump if the comparison result is true.
      • ifNull

        public void ifNull​(org.objectweb.asm.Label label)
        Generates the instruction to jump to the given label if the top stack value is null.
        Parameters:
        label - where to jump if the condition is true.
      • ifNonNull

        public void ifNonNull​(org.objectweb.asm.Label label)
        Generates the instruction to jump to the given label if the top stack value is not null.
        Parameters:
        label - where to jump if the condition is true.
      • goTo

        public void goTo​(org.objectweb.asm.Label label)
        Generates the instruction to jump to the given label.
        Parameters:
        label - where to jump if the condition is true.
      • tableSwitch

        public void tableSwitch​(int[] keys,
                                TableSwitchGenerator generator)
        Generates the instructions for a switch statement.
        Parameters:
        keys - the switch case keys.
        generator - a generator to generate the code for the switch cases.
      • tableSwitch

        public void tableSwitch​(int[] keys,
                                TableSwitchGenerator generator,
                                boolean useTable)
        Generates the instructions for a switch statement.
        Parameters:
        keys - the switch case keys.
        generator - a generator to generate the code for the switch cases.
        useTable - true to use a TABLESWITCH instruction, or false to use a LOOKUPSWITCH instruction.
      • returnValue

        public void returnValue()
        Generates the instruction to return the top stack value to the caller.
      • getStatic

        public void getStatic​(org.objectweb.asm.Type owner,
                              java.lang.String name,
                              org.objectweb.asm.Type type)
        Generates the instruction to push the value of a static field on the stack.
        Parameters:
        owner - the class in which the field is defined.
        name - the name of the field.
        type - the type of the field.
      • putStatic

        public void putStatic​(org.objectweb.asm.Type owner,
                              java.lang.String name,
                              org.objectweb.asm.Type type)
        Generates the instruction to store the top stack value in a static field.
        Parameters:
        owner - the class in which the field is defined.
        name - the name of the field.
        type - the type of the field.
      • getField

        public void getField​(org.objectweb.asm.Type owner,
                             java.lang.String name,
                             org.objectweb.asm.Type type)
        Generates the instruction to push the value of a non static field on the stack.
        Parameters:
        owner - the class in which the field is defined.
        name - the name of the field.
        type - the type of the field.
      • putField

        public void putField​(org.objectweb.asm.Type owner,
                             java.lang.String name,
                             org.objectweb.asm.Type type)
        Generates the instruction to store the top stack value in a non static field.
        Parameters:
        owner - the class in which the field is defined.
        name - the name of the field.
        type - the type of the field.
      • invokeVirtual

        public void invokeVirtual​(org.objectweb.asm.Type owner,
                                  Method method)
        Generates the instruction to invoke a normal method.
        Parameters:
        owner - the class in which the method is defined.
        method - the method to be invoked.
      • invokeConstructor

        public void invokeConstructor​(org.objectweb.asm.Type type,
                                      Method method)
        Generates the instruction to invoke a constructor.
        Parameters:
        type - the class in which the constructor is defined.
        method - the constructor to be invoked.
      • invokeStatic

        public void invokeStatic​(org.objectweb.asm.Type owner,
                                 Method method)
        Generates the instruction to invoke a static method.
        Parameters:
        owner - the class in which the method is defined.
        method - the method to be invoked.
      • invokeInterface

        public void invokeInterface​(org.objectweb.asm.Type owner,
                                    Method method)
        Generates the instruction to invoke an interface method.
        Parameters:
        owner - the class in which the method is defined.
        method - the method to be invoked.
      • invokeDynamic

        public void invokeDynamic​(java.lang.String name,
                                  java.lang.String descriptor,
                                  org.objectweb.asm.Handle bootstrapMethodHandle,
                                  java.lang.Object... bootstrapMethodArguments)
        Generates an invokedynamic instruction.
        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 or Handle value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
      • newInstance

        public void newInstance​(org.objectweb.asm.Type type)
        Generates the instruction to create a new object.
        Parameters:
        type - the class of the object to be created.
      • newArray

        public void newArray​(org.objectweb.asm.Type type)
        Generates the instruction to create a new array.
        Parameters:
        type - the type of the array elements.
      • arrayLength

        public void arrayLength()
        Generates the instruction to compute the length of an array.
      • throwException

        public void throwException()
        Generates the instruction to throw an exception.
      • throwException

        public void throwException​(org.objectweb.asm.Type type,
                                   java.lang.String message)
        Generates the instructions to create and throw an exception. The exception class must have a constructor with a single String argument.
        Parameters:
        type - the class of the exception to be thrown.
        message - the detailed message of the exception.
      • checkCast

        public void checkCast​(org.objectweb.asm.Type type)
        Generates the instruction to check that the top stack value is of the given type.
        Parameters:
        type - a class or interface type.
      • instanceOf

        public void instanceOf​(org.objectweb.asm.Type type)
        Generates the instruction to test if the top stack value is of the given type.
        Parameters:
        type - a class or interface type.
      • monitorEnter

        public void monitorEnter()
        Generates the instruction to get the monitor of the top stack value.
      • monitorExit

        public void monitorExit()
        Generates the instruction to release the monitor of the top stack value.
      • endMethod

        public void endMethod()
        Marks the end of the visited method.
      • catchException

        public void catchException​(org.objectweb.asm.Label start,
                                   org.objectweb.asm.Label end,
                                   org.objectweb.asm.Type exception)
        Marks the start of an exception handler.
        Parameters:
        start - beginning of the exception handler's scope (inclusive).
        end - end of the exception handler's scope (exclusive).
        exception - internal name of the type of exceptions handled by the handler.