Class CodeAttribute

    • Method Detail

      • defineLabel

        public void defineLabel​(String labelName)
        Defines a label. This label may be used as branch target in jump instructions.
        Parameters:
        labelName - a named label at this place of code
      • defineExceptionHandler

        public void defineExceptionHandler​(String startLabelName,
                                           String endLabelName,
                                           Type exceptionType,
                                           String handlerLabelName)
        Defines a try-/catch-block. The try-block must be enclosed with a start and an end label. The entry point of the catch-block (handler) must also be labelled.
        Parameters:
        startLabelName - start label name of try block
        endLabelName - end label name of try block
        exceptionType - exception class or type
        handlerLabelName - start label name of catch block
      • getLocalVariable

        public int getLocalVariable​(String variableName,
                                    Type type)
        Returns the index of a named local variable.
        Parameters:
        variableName - name of variable
        type - type of variable
        Returns:
        index index position
      • nop

        public void nop()
        Opcode nop.
      • loadNull

        public void loadNull()
        Opcode aconst_null.
      • loadConstant

        public void loadConstant​(int value)
        Opcode to load an integer constant (iconst_<n>, bipush, sipush, ldc or ldc_w).
        Parameters:
        value - constant value
      • loadConstant

        public void loadConstant​(long value)
        Opcode to load a long constant (lconst_<n> or ldc2_w).
        Parameters:
        value - constant value
      • loadConstant

        public void loadConstant​(float value)
        Opcode to load a float constant (fconst_<n>, ldc or ldc_w).
        Parameters:
        value - constant value
      • loadConstant

        public void loadConstant​(double value)
        Opcode to load a double constant (dconst_<n> or ldc2_w).
        Parameters:
        value - constant value
      • loadConstant

        public void loadConstant​(String value)
        Opcode to load a string constant (ldc or lcd_w).
        Parameters:
        value - constant value
      • loadConstant

        public void loadConstant​(Type value)
        Opcode to load a class constant (ldc or lcd_w).
        Parameters:
        value - class type as constant value
      • loadLocalInt

        public void loadLocalInt​(String variableName)
        Opcode to load a local int variable by name (iload_<n> or iload).
        Parameters:
        variableName - name of variable
      • loadLocalInt

        public void loadLocalInt​(int index)
        Opcode to load a local int variable (iload_<n> or iload).
        Parameters:
        index - index position of variable
      • loadLocalLong

        public void loadLocalLong​(String variableName)
        Opcode to load a local long variable by name (lload_<n> or lload).
        Parameters:
        variableName - name of variable
      • loadLocalLong

        public void loadLocalLong​(int index)
        Opcode to load a local long variable (lload_<n> or lload).
        Parameters:
        index - index position of variable
      • loadLocalFloat

        public void loadLocalFloat​(String variableName)
        Opcode to load a local float variable by name (fload_<n> or fload).
        Parameters:
        variableName - name of variable
      • loadLocalFloat

        public void loadLocalFloat​(int index)
        Opcode to load a local float variable (fload_<n> or fload).
        Parameters:
        index - index position of variable
      • loadLocalDouble

        public void loadLocalDouble​(String variableName)
        Opcode to load a local double variable by name (dload_<n> or dload).
        Parameters:
        variableName - name of variable
      • loadLocalDouble

        public void loadLocalDouble​(int index)
        Opcode to load a local double variable (dload_<n> or dload).
        Parameters:
        index - index position of variable
      • loadLocalReference

        public void loadLocalReference​(String variableName)
        Opcode to load a local reference variable by name (aload_<n> or aload).
        Parameters:
        variableName - name of variable
      • loadLocalReference

        public void loadLocalReference​(int index)
        Opcode to load a local reference variable (aload_<n> or aload).
        Parameters:
        index - index position of variable
      • loadIntArrayElement

        public void loadIntArrayElement()
        Opcode iaload.
      • loadLongArrayElement

        public void loadLongArrayElement()
        Opcode laload.
      • loadFloatArrayElement

        public void loadFloatArrayElement()
        Opcode faload.
      • loadDoubleArrayElement

        public void loadDoubleArrayElement()
        Opcode daload.
      • loadReferenceArrayElement

        public void loadReferenceArrayElement()
        Opcode aaload.
      • loadBooleanArrayElement

        public void loadBooleanArrayElement()
        Opcode baload (boolean).
      • loadByteArrayElement

        public void loadByteArrayElement()
        Opcode baload (byte).
      • loadCharArrayElement

        public void loadCharArrayElement()
        Opcode caload.
      • loadShortArrayElement

        public void loadShortArrayElement()
        Opcode saload.
      • storeLocalInt

        public void storeLocalInt​(String variableName)
        Opcode to store a local int variable by name (istore_<n> or istore).
        Parameters:
        variableName - name of variable
      • storeLocalInt

        public void storeLocalInt​(int index)
        Opcode to store a local int variable (istore_<n> or istore).
        Parameters:
        index - index position of variable
      • storeLocalLong

        public void storeLocalLong​(String variableName)
        Opcode to store a local long variable by name (lstore_<n> or lstore).
        Parameters:
        variableName - name of variable
      • storeLocalLong

        public void storeLocalLong​(int index)
        Opcode to store a local long variable (lstore_<n> or lstore).
        Parameters:
        index - index position of variable
      • storeLocalFloat

        public void storeLocalFloat​(String variableName)
        Opcode to store a local float variable by name (fstore_<n> or fstore).
        Parameters:
        variableName - name of variable
      • storeLocalFloat

        public void storeLocalFloat​(int index)
        Opcode to store a local float variable (fstore_<n> or fstore).
        Parameters:
        index - index position of variable
      • storeLocalDouble

        public void storeLocalDouble​(String variableName)
        Opcode to store a local double variable by name (dstore_<n> or dstore).
        Parameters:
        variableName - name of variable
      • storeLocalDouble

        public void storeLocalDouble​(int index)
        Opcode to store a local double variable (dstore_<n> or dstore).
        Parameters:
        index - index position of variable
      • storeLocalReference

        public void storeLocalReference​(String variableName)
        Opcode to store a local reference variable by name (astore_<n> or astore).
        Parameters:
        variableName - name of variable
      • storeLocalReference

        public void storeLocalReference​(int index)
        Opcode to store a local reference variable (astore_<n> or astore).
        Parameters:
        index - index position of variable
      • storeIntArrayElement

        public void storeIntArrayElement()
        Opcode iastore.
      • storeLongArrayElement

        public void storeLongArrayElement()
        Opcode lastore.
      • storeFloatArrayElement

        public void storeFloatArrayElement()
        Opcode fastore.
      • storeDoubleArrayElement

        public void storeDoubleArrayElement()
        Opcode dastore.
      • storeReferenceArrayElement

        public void storeReferenceArrayElement()
        Opcode aastore.
      • storeBooleanArrayElement

        public void storeBooleanArrayElement()
        Opcode bastore (boolean).
      • storeByteArrayElement

        public void storeByteArrayElement()
        Opcode bastore (byte).
      • storeCharArrayElement

        public void storeCharArrayElement()
        Opcode castore.
      • storeShortArrayElement

        public void storeShortArrayElement()
        Opcode sastore.
      • pop

        public void pop()
        Opcode pop.
      • popDouble

        public void popDouble()
        Opcode pop2.
      • pop

        public void pop​(int popSize)
        Opcode to pop popSize bytes (pop or pop2 repeatedly).
        Parameters:
        popSize - number of bytes to pop
      • duplicate

        public void duplicate()
        Opcode dup.
      • duplicateSkip

        public void duplicateSkip()
        Opcode dup_x1.
      • duplicateSkipDouble

        public void duplicateSkipDouble()
        Opcode dup_x2.
      • duplicateDouble

        public void duplicateDouble()
        Opcode dup2.
      • duplicateDoubleSkip

        public void duplicateDoubleSkip()
        Opcode dup2_x1.
      • duplicateDoubleSkipDouble

        public void duplicateDoubleSkipDouble()
        Opcode dup2_x2.
      • swap

        public void swap()
        Opcode swap.
      • addInt

        public void addInt()
        Opcode iadd.
      • addLong

        public void addLong()
        Opcode ladd.
      • addFloat

        public void addFloat()
        Opcode fadd.
      • addDouble

        public void addDouble()
        Opcode dadd.
      • subtractInt

        public void subtractInt()
        Opcode isub.
      • subtractLong

        public void subtractLong()
        Opcode lsub.
      • subtractFloat

        public void subtractFloat()
        Opcode fsub.
      • subtractDouble

        public void subtractDouble()
        Opcode dsub.
      • multiplyInt

        public void multiplyInt()
        Opcode imul.
      • multiplyLong

        public void multiplyLong()
        Opcode lmul.
      • multiplyFloat

        public void multiplyFloat()
        Opcode fmul.
      • multiplyDouble

        public void multiplyDouble()
        Opcode dmul.
      • divideInt

        public void divideInt()
        Opcode idiv.
      • divideLong

        public void divideLong()
        Opcode ldiv.
      • divideFloat

        public void divideFloat()
        Opcode fdiv.
      • divideDouble

        public void divideDouble()
        Opcode ddiv.
      • remainderInt

        public void remainderInt()
        Opcode irem.
      • remainderLong

        public void remainderLong()
        Opcode lrem.
      • remainderFloat

        public void remainderFloat()
        Opcode frem.
      • remainderDouble

        public void remainderDouble()
        Opcode drem.
      • negateInt

        public void negateInt()
        Opcode ineg.
      • negateLong

        public void negateLong()
        Opcode lneg.
      • negateFloat

        public void negateFloat()
        Opcode fneg.
      • negateDouble

        public void negateDouble()
        Opcode dneg.
      • shiftLeftInt

        public void shiftLeftInt()
        Opcode ishl.
      • shiftLeftLong

        public void shiftLeftLong()
        Opcode lshl.
      • arithmeticShiftRightInt

        public void arithmeticShiftRightInt()
        Opcode ishr.
      • arithmeticShiftRightLong

        public void arithmeticShiftRightLong()
        Opcode lshr.
      • logicalShiftRightInt

        public void logicalShiftRightInt()
        Opcode iushr.
      • logicalShiftRightLong

        public void logicalShiftRightLong()
        Opcode lushr.
      • booleanAndInt

        public void booleanAndInt()
        Opcode iand.
      • booleanAndLong

        public void booleanAndLong()
        Opcode land.
      • booleanOrInt

        public void booleanOrInt()
        Opcode ior.
      • booleanOrLong

        public void booleanOrLong()
        Opcode lor.
      • booleanXorInt

        public void booleanXorInt()
        Opcode ixor.
      • booleanXorLong

        public void booleanXorLong()
        Opcode lxor.
      • incrementLocalInt

        public void incrementLocalInt​(String variableName,
                                      int increment)
        Opcode to increment a local int variable by name (iinc or a combination of load, add and store).
        Parameters:
        variableName - name of variable
        increment - increment value
      • incrementLocalInt

        public void incrementLocalInt​(int index,
                                      int increment)
        Opcode to increment a local int variable (iinc or a combination of load, add and store).
        Parameters:
        index - index position of variable
        increment - increment value
      • convertIntToLong

        public void convertIntToLong()
        Opcode i2l.
      • convertIntToFloat

        public void convertIntToFloat()
        Opcode i2f.
      • convertIntToDouble

        public void convertIntToDouble()
        Opcode i2d.
      • convertLongToInt

        public void convertLongToInt()
        Opcode l2i.
      • convertLongToFloat

        public void convertLongToFloat()
        Opcode l2f.
      • convertLongToDouble

        public void convertLongToDouble()
        Opcode l2d.
      • convertFloatToInt

        public void convertFloatToInt()
        Opcode f2i.
      • convertFloatToLong

        public void convertFloatToLong()
        Opcode f2l.
      • convertFloatToDouble

        public void convertFloatToDouble()
        Opcode f2d.
      • convertDoubleToInt

        public void convertDoubleToInt()
        Opcode d2i.
      • convertDoubleToLong

        public void convertDoubleToLong()
        Opcode d2l.
      • convertDoubleToFloat

        public void convertDoubleToFloat()
        Opcode d2f.
      • convertIntToByte

        public void convertIntToByte()
        Opcode i2b.
      • convertIntToChar

        public void convertIntToChar()
        Opcode i2c.
      • convertIntToShort

        public void convertIntToShort()
        Opcode i2s.
      • compareLong

        public void compareLong()
        Opcode lcmp.
      • compareFloat

        public void compareFloat​(boolean nanIsMinus)
        Opcode fcmpg or fcmpl.
        Parameters:
        nanIsMinus - flag wether NaN is negative
      • compareDouble

        public void compareDouble​(boolean nanIsMinus)
        Opcode dcmpg or dcmpl.
        Parameters:
        nanIsMinus - flag wether NaN is negative
      • branchIfEqual

        public void branchIfEqual​(String labelName)
        Opcode ifeq. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branchIfNotEqual

        public void branchIfNotEqual​(String labelName)
        Opcode ifne. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branchIfLess

        public void branchIfLess​(String labelName)
        Opcode iflt. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branchIfGreaterEqual

        public void branchIfGreaterEqual​(String labelName)
        Opcode ifge. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branchIfGreater

        public void branchIfGreater​(String labelName)
        Opcode ifgt. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branchIfLessEqual

        public void branchIfLessEqual​(String labelName)
        Opcode ifle. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfEqual

        public void compareIntBranchIfEqual​(String labelName)
        Opcode if_icmpeq. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfNotEqual

        public void compareIntBranchIfNotEqual​(String labelName)
        Opcode if_icmpne. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfLess

        public void compareIntBranchIfLess​(String labelName)
        Opcode if_icmplt. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfGreaterEqual

        public void compareIntBranchIfGreaterEqual​(String labelName)
        Opcode if_icmpge. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfGreater

        public void compareIntBranchIfGreater​(String labelName)
        Opcode if_icmpgt. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareIntBranchIfLessEqual

        public void compareIntBranchIfLessEqual​(String labelName)
        Opcode if_icmple. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareReferenceBranchIfEqual

        public void compareReferenceBranchIfEqual​(String labelName)
        Opcode if_acmpeq. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • compareReferenceBranchIfNotEqual

        public void compareReferenceBranchIfNotEqual​(String labelName)
        Opcode if_acmpne. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • branch

        public void branch​(String labelName)
        Opcode goto. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • jumpSubroutine

        public void jumpSubroutine​(String labelName)
        Opcode jsr. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - name of label to branch to
      • returnFromSubroutine

        public void returnFromSubroutine​(String variableName)
        Opcode ret (address variable by name).
        Parameters:
        variableName - name of variable
      • returnFromSubroutine

        public void returnFromSubroutine​(int index)
        Opcode ret.
        Parameters:
        index - index position of variable
      • tableswitch

        public void tableswitch​(BranchTable table)
        Opcode tableswitch.
        Parameters:
        table - branch table with case entries
      • lookupswitch

        public void lookupswitch​(BranchTable table)
        Opcode lookupswitch.
        Parameters:
        table - branch table with case entries
      • returnInt

        public void returnInt()
        Opcode ireturn.
      • returnLong

        public void returnLong()
        Opcode lreturn.
      • returnFloat

        public void returnFloat()
        Opcode freturn.
      • returnDouble

        public void returnDouble()
        Opcode dreturn.
      • returnReference

        public void returnReference()
        Opcode areturn.
      • returnVoid

        public void returnVoid()
        Opcode return.
      • getStatic

        public void getStatic​(Type fieldClass,
                              Type fieldType,
                              String fieldName)
        Opcode getstatic.
        Parameters:
        fieldClass - member class of field
        fieldType - type of field
        fieldName - name of field
      • putStatic

        public void putStatic​(Type fieldClass,
                              Type fieldType,
                              String fieldName)
        Opcode putstatic.
        Parameters:
        fieldClass - member class of field
        fieldType - type of field
        fieldName - name of field
      • getField

        public void getField​(Type fieldClass,
                             Type fieldType,
                             String fieldName)
        Opcode getfield.
        Parameters:
        fieldClass - member class of field
        fieldType - type of field
        fieldName - name of field
      • putField

        public void putField​(Type fieldClass,
                             Type fieldType,
                             String fieldName)
        Opcode putfield.
        Parameters:
        fieldClass - member class of field
        fieldType - type of field
        fieldName - name of field
      • invokeVirtual

        public void invokeVirtual​(Type methodClass,
                                  Type returnType,
                                  String methodName,
                                  Type... argTypes)
        Opcode invokevirtual.
        Parameters:
        methodClass - member class of method
        returnType - type of return value
        methodName - method name
        argTypes - types of arguments
      • invokeSpecial

        public void invokeSpecial​(Type methodClass,
                                  Type returnType,
                                  String methodName,
                                  Type... argTypes)
        Opcode invokespecial.
        Parameters:
        methodClass - member class of method
        returnType - type of return value
        methodName - method name
        argTypes - types of arguments
      • invokeStatic

        public void invokeStatic​(Type methodClass,
                                 Type returnType,
                                 String methodName,
                                 Type... argTypes)
        Opcode invokestatic.
        Parameters:
        methodClass - member class of method
        returnType - type of return value
        methodName - method name
        argTypes - types of arguments
      • invokeInterface

        public void invokeInterface​(Type methodClass,
                                    Type returnType,
                                    String methodName,
                                    Type... argTypes)
        Opcode invokeinterface.
        Parameters:
        methodClass - interface class of method
        returnType - type of return value
        methodName - method name
        argTypes - types of arguments
      • newObject

        public void newObject​(Type clazz)
        Opcode new.
        Parameters:
        clazz - class type
      • newArray

        public void newArray​(Type elementType)
        Opcode newarray or anewarray.
        Parameters:
        elementType - array element type
      • arraylength

        public void arraylength()
        Opcode arraylength.
      • throwException

        public void throwException()
        Opcode athrow.
      • cast

        public void cast​(Type checkedType)
        Opcode checkcast.
        Parameters:
        checkedType - type to cast
      • checkInstance

        public void checkInstance​(Type checkedType)
        Opcode instanceof.
        Parameters:
        checkedType - type of instance
      • monitorEnter

        public void monitorEnter()
        Opcode monitorenter.
      • monitorExit

        public void monitorExit()
        Opcode monitorexit.
      • newMultiReferenceArray

        public void newMultiReferenceArray​(Type clazz,
                                           int dimensions)
        Opcode multianewarray.
        Parameters:
        clazz - element class type
        dimensions - number of dimensions
      • branchIfNull

        public void branchIfNull​(String labelName)
        Opcode ifnull. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - label name to branch to
      • branchIfNonNull

        public void branchIfNonNull​(String labelName)
        Opcode ifnonnull. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - label name to branch to
      • branchFar

        public void branchFar​(String labelName)
        Opcode goto_w. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - label name to branch to
      • jumpFarSubroutine

        public void jumpFarSubroutine​(String labelName)
        Opcode jsr_w. The label must be defined by defineLabel(java.lang.String).
        Parameters:
        labelName - label name to branch to