Package org.jboss.classfilewriter.code

## Class CodeAttribute

- java.lang.Object
- - org.jboss.classfilewriter.attributes.Attribute
  - - org.jboss.classfilewriter.code.CodeAttribute

All Implemented Interfaces:
  `WritableEntry`

    public class CodeAttribute
    extends Attribute

### Nested Class Summary

Nested Classes
`static interface` `CodeAttribute.StackFrameTypeResolver` Interface that can be used to override the type merging process when merging stack frames

### Field Summary

Fields
`static String` `NAME`

### Constructor Summary

Constructors
`CodeAttribute​(ClassMethod method, ConstPool constPool)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `aaload​()`
`void` `aastore​()`
`void` `aconstNull​()`
`void` `aload​(int no)`
`void` `anewarray​(String arrayType)`
`void` `arraylength​()`
`void` `assertNotWideOnStack​(int position, String message)`
`void` `assertNotWideOnStack​(String message)`
`void` `assertTypeOnStack​(int position, StackEntryType type, String message)`
`void` `assertTypeOnStack​(StackEntryType type, String message)`
`void` `astore​(int no)`
`void` `athrow​()`
`void` `baload​()`
`void` `bastore​()`
`void` `bipush​(byte value)`
`void` `branchEnd​(BranchEnd end)` marks the end of a branch.
`void` `caload​()`
`void` `castore​()`
`void` `checkcast​(Class<?> clazz)`
`void` `checkcast​(String className)` Do not use Descriptor format (e.g.
`void` `d2f​()`
`void` `d2i​()`
`void` `d2l​()`
`void` `dadd​()`
`void` `daload​()`
`void` `dastore​()`
`void` `dcmpg​()`
`void` `dcmpl​()`
`void` `dconst​(double value)` Adds the appropriate dconst instruction.
`void` `ddiv​()`
`void` `dload​(int no)`
`void` `dmul​()`
`void` `dneg​()`
`void` `drem​()`
`void` `dstore​(int no)`
`void` `dsub​()`
`void` `dup​()`
`void` `dup2​()`
`void` `dup2X1​()`
`void` `dup2X2​()`
`void` `dupX1​()`
`void` `dupX2​()`
`void` `exceptionBlockEnd​(ExceptionHandler handler)` Mark the end of an exception handler block.
`ExceptionHandler` `exceptionBlockStart​(String exceptionType)` Begin writing an exception handler block.
`void` `exceptionHandlerStart​(ExceptionHandler handler)` Marks the current code location as the exception handler and adds the handler to the exception handler table;
`void` `f2d​()`
`void` `f2i​()`
`void` `f2l​()`
`void` `fadd​()`
`void` `faload​()`
`void` `fastore​()`
`void` `fcmpg​()`
`void` `fcmpl​()`
`void` `fconst​(float value)` Adds the appropriate fconst instruction.
`void` `fdiv​()`
`void` `fload​(int no)`
`void` `fmul​()`
`void` `fneg​()`
`void` `frem​()`
`void` `fstore​(int no)`
`void` `fsub​()`
`ConstPool` `getConstPool​()`
`void` `getfield​(String className, String field, Class<?> fieldType)`
`void` `getfield​(String className, String field, String descriptor)`
`LinkedHashMap<Integer,StackFrame>` `getStackFrames​()`
`CodeAttribute.StackFrameTypeResolver` `getStackFrameTypeResolver​()`
`void` `getstatic​(String className, String field, Class<?> fieldType)`
`void` `getstatic​(String className, String field, String descriptor)`
`BranchEnd` `gotoInstruction​()` writes a goto instruction.
`void` `gotoInstruction​(CodeLocation location)` writes a goto instruction.
`void` `i2b​()`
`void` `i2c​()`
`void` `i2d​()`
`void` `i2f​()`
`void` `i2l​()`
`void` `i2s​()`
`void` `iadd​()`
`void` `iaload​()`
`void` `iand​()`
`void` `iastore​()`
`void` `iconst​(int value)` Adds the appropriate iconst instruction.
`void` `idiv​()`
`BranchEnd` `ifAcmpeq​()`
`void` `ifAcmpeq​(CodeLocation location)`
`BranchEnd` `ifAcmpne​()`
`void` `ifAcmpne​(CodeLocation location)`
`BranchEnd` `ifeq​()`
`void` `ifEq​(CodeLocation location)`
`BranchEnd` `ifge​()`
`void` `ifge​(CodeLocation location)`
`BranchEnd` `ifgt​()`
`void` `ifgt​(CodeLocation location)`
`BranchEnd` `ifIcmpeq​()`
`void` `ifIcmpeq​(CodeLocation location)`
`BranchEnd` `ifIcmpge​()`
`void` `ifIcmpge​(CodeLocation location)`
`BranchEnd` `ifIcmpgt​()`
`void` `ifIcmpgt​(CodeLocation location)`
`BranchEnd` `ifIcmple​()`
`void` `ifIcmple​(CodeLocation location)`
`BranchEnd` `ifIcmplt​()`
`void` `ifIcmplt​(CodeLocation location)`
`BranchEnd` `ifIcmpne​()`
`void` `ifIcmpne​(CodeLocation location)`
`BranchEnd` `ifle​()`
`void` `ifle​(CodeLocation location)`
`BranchEnd` `iflt​()`
`void` `iflt​(CodeLocation location)`
`BranchEnd` `ifne​()`
`void` `ifne​(CodeLocation location)`
`BranchEnd` `ifnotnull​()`
`void` `ifnotnull​(CodeLocation location)`
`BranchEnd` `ifnull​()` Jump to the given location if the reference type on the top of the stack is null.
`void` `ifnull​(CodeLocation location)` Jump to the given location if the reference type on the top of the stack is null
`void` `iinc​(int local, int amount)`
`void` `iload​(int no)`
`void` `imul​()`
`void` `ineg​()`
`void` `instanceofInstruction​(String className)`
`void` `invokeinterface​(Method method)`
`void` `invokeinterface​(String className, String methodName, String descriptor)`
`void` `invokeinterface​(String className, String methodName, String returnType, String[] parameterTypes)`
`void` `invokespecial​(Constructor<?> constructor)`
`void` `invokespecial​(Method method)`
`void` `invokespecial​(String className, String methodName, String descriptor)`
`void` `invokespecial​(String className, String methodName, String returnType, String[] parameterTypes)`
`void` `invokestatic​(Method method)`
`void` `invokestatic​(String className, String methodName, String descriptor)`
`void` `invokestatic​(String className, String methodName, String returnType, String[] parameterTypes)`
`void` `invokevirtual​(Method method)`
`void` `invokevirtual​(String className, String methodName, String descriptor)`
`void` `invokevirtual​(String className, String methodName, String returnType, String[] parameterTypes)`
`void` `ior​()`
`void` `irem​()`
`void` `ishl​()`
`void` `ishr​()`
`void` `istore​(int no)`
`void` `isub​()`
`void` `iushr​()`
`void` `ixor​()`
`void` `l2d​()`
`void` `l2f​()`
`void` `l2i​()`
`void` `ladd​()`
`void` `laload​()`
`void` `land​()`
`void` `lastore​()`
`void` `lcmp​()`
`void` `lconst​(long value)` Adds the appropriate lconst instruction.
`void` `ldc​(float value)` Adds an ldc instruction for float
`void` `ldc​(int value)` Adds an ldc instruction for an int.
`void` `ldc​(String value)` Adds an ldc instruction for a String
`void` `ldc2​(double value)` Adds an ldc2_w instruction for double
`void` `ldc2​(long value)` Adds an ldc2_w instruction for long
`void` `ldiv​()`
`void` `lload​(int no)`
`void` `lmul​()`
`void` `lneg​()`
`void` `load​(Class<?> type, int no)` Generates the apprpriate load instruction for the given type
`void` `load​(String descriptor, int no)` Generates the apprpriate load instruction for the given type
`void` `loadClass​(String className)`
`void` `loadMethodParameters​()` loads all parameters onto the stack.
`void` `loadType​(String descriptor)` Loads a java.lang.Class for the given descriptor into the stack.
`void` `lookupswitch​(LookupSwitchBuilder lookupSwitchBuilder)` Adds a lookup switch statement
`void` `lor​()`
`void` `lrem​()`
`void` `lshl​()`
`void` `lshr​()`
`void` `lstore​(int no)`
`void` `lsub​()`
`void` `lushr​()`
`void` `lxor​()`
`CodeLocation` `mark​()` Gets the location object for the current location in the bytecode.
`void` `monitorenter​()`
`void` `monitorexit​()`
`void` `multianewarray​(String arrayType, int dimensions)`
`void` `newarray​(Class<?> arrayType)` arrayType must be a `Class` object that represents a primitive type
`void` `newInstruction​(Class<?> clazz)`
`void` `newInstruction​(String classname)`
`void` `nop​()`
`void` `pop​()`
`void` `pop2​()`
`void` `putfield​(String className, String field, Class<?> fieldType)`
`void` `putfield​(String className, String field, String descriptor)`
`void` `putstatic​(String className, String field, Class<?> fieldType)`
`void` `putstatic​(String className, String field, String descriptor)`
`void` `returnInstruction​()` Adds the appropriate return instruction for the methods return type.
`void` `saload​()`
`void` `sastore​()`
`void` `setStackFrameTypeResolver​(CodeAttribute.StackFrameTypeResolver stackFrameTypeResolver)`
`void` `setupFrame​(String... types)`
`void` `sipush​(short value)`
`void` `swap​()`
`void` `tableswitch​(TableSwitchBuilder builder)`
`void` `writeData​(ByteArrayDataOutputStream stream)`

### Methods inherited from class org.jboss.classfilewriter.attributes.Attribute

`getName, write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### NAME

    public static final String NAME

See Also:
  Constant Field Values

### Constructor Detail

#### CodeAttribute

    public CodeAttribute​(ClassMethod method,
                         ConstPool constPool)

### Method Detail

#### getStackFrameTypeResolver

    public CodeAttribute.StackFrameTypeResolver getStackFrameTypeResolver​()

#### setStackFrameTypeResolver

    public void setStackFrameTypeResolver​(CodeAttribute.StackFrameTypeResolver stackFrameTypeResolver)

#### writeData

    public void writeData​(ByteArrayDataOutputStream stream)
                   throws IOException

Specified by:
  `writeData` in class `Attribute`
Throws:
  `IOException`

#### aaload

    public void aaload​()

#### aastore

    public void aastore​()

#### aconstNull

    public void aconstNull​()

#### aload

    public void aload​(int no)

#### anewarray

    public void anewarray​(String arrayType)

#### arraylength

    public void arraylength​()

#### astore

    public void astore​(int no)

#### athrow

    public void athrow​()

#### baload

    public void baload​()

#### bastore

    public void bastore​()

#### caload

    public void caload​()

#### castore

    public void castore​()

#### bipush

    public void bipush​(byte value)

#### branchEnd

    public void branchEnd​(BranchEnd end)

marks the end of a branch. The current stack frame is checked for compatibility with the stack frame at the branch start

#### checkcast

    public void checkcast​(String className)

Do not use Descriptor format (e.g. Ljava/lang/Object;), the correct form is just java/lang/Object or java.lang.Object

#### checkcast

    public void checkcast​(Class<?> clazz)

#### d2f

    public void d2f​()

#### d2i

    public void d2i​()

#### d2l

    public void d2l​()

#### dadd

    public void dadd​()

#### daload

    public void daload​()

#### dastore

    public void dastore​()

#### dcmpg

    public void dcmpg​()

#### dcmpl

    public void dcmpl​()

#### dconst

    public void dconst​(double value)

Adds the appropriate dconst instruction.

note, if the value is not 0 or 1 then ldc is used instead

#### ddiv

    public void ddiv​()

#### dload

    public void dload​(int no)

#### dmul

    public void dmul​()

#### dneg

    public void dneg​()

#### drem

    public void drem​()

#### dstore

    public void dstore​(int no)

#### dsub

    public void dsub​()

#### dup

    public void dup​()

#### dupX1

    public void dupX1​()

#### dupX2

    public void dupX2​()

#### dup2

    public void dup2​()

#### dup2X1

    public void dup2X1​()

#### dup2X2

    public void dup2X2​()

#### exceptionBlockStart

    public ExceptionHandler exceptionBlockStart​(String exceptionType)

Begin writing an exception handler block. The handler is not actually persisted until exceptionHandler is called.

#### exceptionBlockEnd

    public void exceptionBlockEnd​(ExceptionHandler handler)

Mark the end of an exception handler block. The last instruction that was written will be the last instruction covered by the handler

#### exceptionHandlerStart

    public void exceptionHandlerStart​(ExceptionHandler handler)

Marks the current code location as the exception handler and adds the handler to the exception handler table;

#### f2d

    public void f2d​()

#### f2i

    public void f2i​()

#### f2l

    public void f2l​()

#### fadd

    public void fadd​()

#### faload

    public void faload​()

#### fastore

    public void fastore​()

#### fcmpg

    public void fcmpg​()

#### fcmpl

    public void fcmpl​()

#### fconst

    public void fconst​(float value)

Adds the appropriate fconst instruction.

note, if the value is not 0, 1, 2 then ldc is used instead

#### fdiv

    public void fdiv​()

#### fload

    public void fload​(int no)

#### fmul

    public void fmul​()

#### fneg

    public void fneg​()

#### frem

    public void frem​()

#### fstore

    public void fstore​(int no)

#### fsub

    public void fsub​()

#### getfield

    public void getfield​(String className,
                         String field,
                         Class<?> fieldType)

#### getfield

    public void getfield​(String className,
                         String field,
                         String descriptor)

#### getstatic

    public void getstatic​(String className,
                          String field,
                          Class<?> fieldType)

#### getstatic

    public void getstatic​(String className,
                          String field,
                          String descriptor)

#### gotoInstruction

    public void gotoInstruction​(CodeLocation location)

writes a goto instruction.

TODO: implemented goto_w

#### gotoInstruction

    public BranchEnd gotoInstruction​()

writes a goto instruction.

TODO: implemented goto_w

#### i2b

    public void i2b​()

#### i2c

    public void i2c​()

#### i2d

    public void i2d​()

#### i2f

    public void i2f​()

#### i2l

    public void i2l​()

#### i2s

    public void i2s​()

#### iadd

    public void iadd​()

#### iaload

    public void iaload​()

#### iand

    public void iand​()

#### iastore

    public void iastore​()

#### iconst

    public void iconst​(int value)

Adds the appropriate iconst instruction.

note, if the value is not in the range -1 to 5 ldc is written instead

Parameters:
  `value` -

#### idiv

    public void idiv​()

#### ifAcmpeq

    public void ifAcmpeq​(CodeLocation location)

#### ifAcmpeq

    public BranchEnd ifAcmpeq​()

#### ifAcmpne

    public void ifAcmpne​(CodeLocation location)

#### ifAcmpne

    public BranchEnd ifAcmpne​()

#### ifIcmpeq

    public void ifIcmpeq​(CodeLocation location)

#### ifIcmpeq

    public BranchEnd ifIcmpeq​()

#### ifIcmpne

    public void ifIcmpne​(CodeLocation location)

#### ifIcmpne

    public BranchEnd ifIcmpne​()

#### ifIcmplt

    public void ifIcmplt​(CodeLocation location)

#### ifIcmplt

    public BranchEnd ifIcmplt​()

#### ifIcmple

    public void ifIcmple​(CodeLocation location)

#### ifIcmple

    public BranchEnd ifIcmple​()

#### ifIcmpgt

    public void ifIcmpgt​(CodeLocation location)

#### ifIcmpgt

    public BranchEnd ifIcmpgt​()

#### ifIcmpge

    public void ifIcmpge​(CodeLocation location)

#### ifIcmpge

    public BranchEnd ifIcmpge​()

#### ifEq

    public void ifEq​(CodeLocation location)

#### ifeq

    public BranchEnd ifeq​()

#### ifne

    public void ifne​(CodeLocation location)

#### ifne

    public BranchEnd ifne​()

#### iflt

    public void iflt​(CodeLocation location)

#### iflt

    public BranchEnd iflt​()

#### ifle

    public void ifle​(CodeLocation location)

#### ifle

    public BranchEnd ifle​()

#### ifgt

    public void ifgt​(CodeLocation location)

#### ifgt

    public BranchEnd ifgt​()

#### ifge

    public void ifge​(CodeLocation location)

#### ifge

    public BranchEnd ifge​()

#### ifnotnull

    public void ifnotnull​(CodeLocation location)

#### ifnotnull

    public BranchEnd ifnotnull​()

#### ifnull

    public void ifnull​(CodeLocation location)

Jump to the given location if the reference type on the top of the stack is null

#### ifnull

    public BranchEnd ifnull​()

Jump to the given location if the reference type on the top of the stack is null.

The `BranchEnd` returned from this method is used to set the end point to a future point in the bytecode stream

#### iinc

    public void iinc​(int local,
                     int amount)

#### iload

    public void iload​(int no)

#### imul

    public void imul​()

#### ineg

    public void ineg​()

#### instanceofInstruction

    public void instanceofInstruction​(String className)

#### invokespecial

    public void invokespecial​(String className,
                              String methodName,
                              String descriptor)

#### invokespecial

    public void invokespecial​(String className,
                              String methodName,
                              String returnType,
                              String[] parameterTypes)

#### invokespecial

    public void invokespecial​(Constructor<?> constructor)

#### invokespecial

    public void invokespecial​(Method method)

#### invokestatic

    public void invokestatic​(String className,
                             String methodName,
                             String descriptor)

#### invokestatic

    public void invokestatic​(String className,
                             String methodName,
                             String returnType,
                             String[] parameterTypes)

#### invokestatic

    public void invokestatic​(Method method)

#### invokevirtual

    public void invokevirtual​(String className,
                              String methodName,
                              String descriptor)

#### invokevirtual

    public void invokevirtual​(String className,
                              String methodName,
                              String returnType,
                              String[] parameterTypes)

#### invokevirtual

    public void invokevirtual​(Method method)

#### invokeinterface

    public void invokeinterface​(String className,
                                String methodName,
                                String descriptor)

#### invokeinterface

    public void invokeinterface​(String className,
                                String methodName,
                                String returnType,
                                String[] parameterTypes)

#### invokeinterface

    public void invokeinterface​(Method method)

#### ior

    public void ior​()

#### irem

    public void irem​()

#### ishl

    public void ishl​()

#### ishr

    public void ishr​()

#### istore

    public void istore​(int no)

#### isub

    public void isub​()

#### iushr

    public void iushr​()

#### ixor

    public void ixor​()

#### l2d

    public void l2d​()

#### l2f

    public void l2f​()

#### l2i

    public void l2i​()

#### ladd

    public void ladd​()

#### laload

    public void laload​()

#### land

    public void land​()

#### lastore

    public void lastore​()

#### lcmp

    public void lcmp​()

#### lconst

    public void lconst​(long value)

Adds the appropriate lconst instruction.

note, if the value is not 0 or 1 then ldc is used instead

#### ldc

    public void ldc​(int value)

Adds an ldc instruction for an int.

Parameters:
  `value` - The value to load

#### ldc

    public void ldc​(float value)

Adds an ldc instruction for float

#### ldc

    public void ldc​(String value)

Adds an ldc instruction for a String

To load a class literal using ldc use the @{link #loadType(String)} method.

#### ldc2

    public void ldc2​(double value)

Adds an ldc2_w instruction for double

#### ldc2

    public void ldc2​(long value)

Adds an ldc2_w instruction for long

#### ldiv

    public void ldiv​()

#### lload

    public void lload​(int no)

#### lmul

    public void lmul​()

#### lneg

    public void lneg​()

#### load

    public void load​(Class<?> type,
                     int no)

Generates the apprpriate load instruction for the given type

Parameters:
  `type` - The type of variable
  `no` - local variable number

#### load

    public void load​(String descriptor,
                     int no)

Generates the apprpriate load instruction for the given type

Parameters:
  `descriptor` - The descriptor of the variable
  `no` - local variable number

#### loadClass

    public void loadClass​(String className)

#### loadType

    public void loadType​(String descriptor)

Loads a java.lang.Class for the given descriptor into the stack.

#### lookupswitch

    public void lookupswitch​(LookupSwitchBuilder lookupSwitchBuilder)

Adds a lookup switch statement

Parameters:
  `lookupSwitchBuilder` -

#### lor

    public void lor​()

#### lrem

    public void lrem​()

#### lshl

    public void lshl​()

#### lshr

    public void lshr​()

#### lstore

    public void lstore​(int no)

#### lsub

    public void lsub​()

#### lushr

    public void lushr​()

#### lxor

    public void lxor​()

#### mark

    public CodeLocation mark​()

Gets the location object for the current location in the bytecode. Jumps to this location will begin executing the next instruction that is written to the bytecode stream

#### monitorenter

    public void monitorenter​()

#### monitorexit

    public void monitorexit​()

#### multianewarray

    public void multianewarray​(String arrayType,
                               int dimensions)

#### newInstruction

    public void newInstruction​(String classname)

#### newInstruction

    public void newInstruction​(Class<?> clazz)

#### newarray

    public void newarray​(Class<?> arrayType)

arrayType must be a `Class` object that represents a primitive type

#### nop

    public void nop​()

#### pop

    public void pop​()

#### pop2

    public void pop2​()

#### putfield

    public void putfield​(String className,
                         String field,
                         Class<?> fieldType)

#### putfield

    public void putfield​(String className,
                         String field,
                         String descriptor)

#### putstatic

    public void putstatic​(String className,
                          String field,
                          Class<?> fieldType)

#### putstatic

    public void putstatic​(String className,
                          String field,
                          String descriptor)

#### returnInstruction

    public void returnInstruction​()

Adds the appropriate return instruction for the methods return type.

#### saload

    public void saload​()

#### sastore

    public void sastore​()

#### sipush

    public void sipush​(short value)

#### swap

    public void swap​()

#### tableswitch

    public void tableswitch​(TableSwitchBuilder builder)

#### loadMethodParameters

    public void loadMethodParameters​()

loads all parameters onto the stack.

If this method is non-static then the parameter at location 0 (i.e. this object) is not pushed.

#### getStackFrames

    public LinkedHashMap<Integer,StackFrame> getStackFrames​()

#### setupFrame

    public void setupFrame​(String... types)

#### getConstPool

    public ConstPool getConstPool​()

#### assertTypeOnStack

    public void assertTypeOnStack​(int position,
                                  StackEntryType type,
                                  String message)

#### assertTypeOnStack

    public void assertTypeOnStack​(StackEntryType type,
                                  String message)

#### assertNotWideOnStack

    public void assertNotWideOnStack​(int position,
                                     String message)

#### assertNotWideOnStack

    public void assertNotWideOnStack​(String message)