APIdia Launch Partner
Top Description Inners Methods
java.lang.classfile

public sealed Interface CodeBuilder

extends ClassFileBuilder<CodeElement, CodeBuilder>
permits BlockCodeBuilder, ChainedCodeBuilder, TerminalCodeBuilder, NonterminalCodeBuilder
Known Direct Subinterfaces
java.lang.classfile.CodeBuilder.BlockCodeBuilder, jdk.internal.classfile.impl.TerminalCodeBuilder
Known Direct Implementers
jdk.internal.classfile.impl.ChainedCodeBuilder, jdk.internal.classfile.impl.NonterminalCodeBuilder
Imports
java.lang.classfile.ClassFile.*, java.lang.classfile.constantpool.*, java.lang.classfile.instruction.*, java.lang.constant.ClassDesc, .ConstantDesc, .ConstantDescs, .DirectMethodHandleDesc, .DynamicCallSiteDesc, .MethodTypeDesc, java.util.ArrayList, .List, .Optional, java.util.function.Consumer, jdk.internal.classfile.impl.*

A builder for Code attributes (method bodies). MethodBuilder#withCode is the basic way to obtain a code builder; ClassBuilder#withMethodBody is a shortcut. There are also derived code builders from block, which handles code blocks and transforming, which runs transforms on existing handlers, both of which requires a code builder to be available first.

Refer to ClassFileBuilder for general guidance and caution around the use of builders for structures in the class file format. Unlike in other builders, the order of member elements in a code builder is significant: they affect the resulting bytecode. Many Class-File API options affect code builders: DeadCodeOption and ShortJumpsOption affect the resulting bytecode, and DeadLabelsOption, DebugElementsOption, LineNumbersOption, StackMapsOption, and AttributesProcessingOption affect the resulting attributes on the built Code attribute, that some elements sent to a code builder is otherwise ignored.

Instruction Factories

CodeBuilder provides convenience methods to create instructions (See JVMS 6.5 Instructions) by their mnemonic, taking necessary operands.
Since
24
See Also
MethodBuilder#withCode, CodeModel, CodeTransform

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
CodeBuilder.BlockCodeBuilder

A builder for blocks of code.

public static interface
CodeBuilder.CatchBuilder

A builder to add catch blocks.

Method Summary

Modifier and TypeMethod and Description
public default CodeBuilder

Returns:

this builder
aaload
()

Generates an instruction to load from a reference array.

public default CodeBuilder

Returns:

this builder
aastore
()

Generates an instruction to store into a reference array.

public default CodeBuilder

Returns:

this builder
aconst_null
()

Generates an instruction pushing the null object reference onto the operand stack.

public int

Returns:

the local variable slot of a fresh local variable
allocateLocal
(TypeKind
the type of the local variable
typeKind
)

Returns the local variable slot of a fresh local variable.

public default CodeBuilder

Returns:

this builder
aload
(int
the local variable slot
slot
)

Generates an instruction to load a reference from a local variable.

public default CodeBuilder

Returns:

this builder
anewarray
(ClassEntry
the component type
classEntry
)

Generates an instruction to create a new array of reference.

public default CodeBuilder

Returns:

this builder
anewarray
(ClassDesc
the component type
className
)

Generates an instruction to create a new array of reference.

public default CodeBuilder

Returns:

this builder
areturn
()

Generates an instruction to return a reference from this method.

public default CodeBuilder

Returns:

this builder
arraylength
()

Generates an instruction to get the length of an array.

public default CodeBuilder

Returns:

this builder
arrayLoad
(TypeKind
the array element type
tk
)

Generates an instruction to load from an array.

public default CodeBuilder

Returns:

this builder
arrayStore
(TypeKind
the array element type
tk
)

Generates an instruction to store into an array.

public default CodeBuilder

Returns:

this builder
astore
(int
the local variable slot
slot
)

Generates an instruction to store a reference into a local variable.

public default CodeBuilder

Returns:

this builder
athrow
()

Generates an instruction to throw an exception or error.

public default CodeBuilder

Returns:

this builder
baload
()

Generates an instruction to load from a byte or boolean array.

public default CodeBuilder

Returns:

this builder
bastore
()

Generates an instruction to store into a byte or boolean array.

public default CodeBuilder

Returns:

this builder
bipush
(int
the int in the range of byte
b
)

Generates an instruction pushing an int in the range of byte ([-128, 127]) onto the operand stack.

public default CodeBuilder

Returns:

this builder
block
(Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the lexical block
handler
)

Adds a lexical block to the method being built.

public default CodeBuilder

Returns:

this builder
branch
(Opcode
the branch opcode
op
,
Label
the branch target
target
)

Generates a branch instruction.

public default CodeBuilder

Returns:

this builder
caload
()

Generates an instruction to load from a char array.

public default CodeBuilder

Returns:

this builder
castore
()

Generates an instruction to store into a char array.

public default CodeBuilder

Returns:

this builder
characterRange
(Label
the start scope of the character range
startScope
,
Label
the end scope of the character range
endScope
,
int
the encoded start of the character range region (inclusive)
characterRangeStart
,
int
the encoded end of the character range region (exclusive)
characterRangeEnd
,
int
the flags word, indicating the kind of range
flags
)

Declares a character range entry.

public default CodeBuilder

Returns:

this builder
checkcast
(ClassEntry
the object type
type
)

Generates an instruction to check whether an object is of the given type, throwing a ClassCastException if the check fails.

public default CodeBuilder

Returns:

this builder
checkcast
(ClassDesc
the object type
type
)

Generates an instruction to check whether an object is of the given type, throwing a ClassCastException if the check fails.

public default CodeBuilder

Returns:

this builder
conversion
(TypeKind
the source type
fromType
,
TypeKind
the target type
toType
)

Generates instruction(s) to convert fromType to toType.

public default CodeBuilder

Returns:

this builder
d2f
()

Generates an instruction to convert a double into a float.

public default CodeBuilder

Returns:

this builder
d2i
()

Generates an instruction to convert a double into an int.

public default CodeBuilder

Returns:

this builder
d2l
()

Generates an instruction to convert a double into a long.

public default CodeBuilder

Returns:

this builder
dadd
()

Generates an instruction to add two doubles.

public default CodeBuilder

Returns:

this builder
daload
()

Generates an instruction to load from a double array.

public default CodeBuilder

Returns:

this builder
dastore
()

Generates an instruction to store into a double array.

public default CodeBuilder

Returns:

this builder
dcmpg
()

Generates an instruction to compare two doubles, producing 1 if any operand is NaN.

public default CodeBuilder

Returns:

this builder
dcmpl
()

Generates an instruction to compare two doubles, producing -1 if any operand is NaN.

public default CodeBuilder

Returns:

this builder
dconst_0
()

Generates an instruction pushing double constant 0 onto the operand stack.

public default CodeBuilder

Returns:

this builder
dconst_1
()

Generates an instruction pushing double constant 1 onto the operand stack.

public default CodeBuilder

Returns:

this builder
ddiv
()

Generates an instruction to divide doubles.

public default CodeBuilder

Returns:

this builder
dload
(int
the local variable slot
slot
)

Generates an instruction to load a double from a local variable.

public default CodeBuilder

Returns:

this builder
dmul
()

Generates an instruction to multiply doubles.

public default CodeBuilder

Returns:

this builder
dneg
()

Generates an instruction to negate a double.

public default CodeBuilder

Returns:

this builder
drem
()

Generates an instruction to calculate double remainder.

public default CodeBuilder

Returns:

this builder
dreturn
()

Generates an instruction to return a double from this method.

public default CodeBuilder

Returns:

this builder
dstore
(int
the local variable slot
slot
)

Generates an instruction to store a double into a local variable.

public default CodeBuilder

Returns:

this builder
dsub
()

Generates an instruction to subtract doubles.

public default CodeBuilder

Returns:

this builder
dup
()

Generates an instruction to duplicate the top operand stack value.

public default CodeBuilder

Returns:

this builder
dup2
()

Generates an instruction to duplicate the top one or two operand stack value.

public default CodeBuilder

Returns:

this builder
dup2_x1
()

Generates an instruction to duplicate the top one or two operand stack values and insert two or three values down.

public default CodeBuilder

Returns:

this builder
dup2_x2
()

Generates an instruction to duplicate the top one or two operand stack values and insert two, three, or four values down.

public default CodeBuilder

Returns:

this builder
dup_x1
()

Generates an instruction to duplicate the top operand stack value and insert two values down.

public default CodeBuilder

Returns:

this builder
dup_x2
()

Generates an instruction to duplicate the top operand stack value and insert two or three values down.

public Label

Returns:

the label associated with the end of the current block
endLabel
()

Returns the label associated with the end of the current block.

public default CodeBuilder

Returns:

this builder
exceptionCatch
(Label
the try block start
start
,
Label
the try block end
end
,
Label
the exception handler start
handler
,
ClassEntry
the catch type, may be null to catch all exceptions and errors
catchType
)

Declares an exception table entry.

public default CodeBuilder

Returns:

this builder
exceptionCatch
(Label
the try block start
start
,
Label
the try block end
end
,
Label
the exception handler start
handler
,
Optional<ClassEntry>
the optional catch type, empty to catch all exceptions and errors
catchType
)

Declares an exception table entry.

public default CodeBuilder

Returns:

this builder
exceptionCatch
(Label
the try block start
start
,
Label
the try block end
end
,
Label
the exception handler start
handler
,
ClassDesc
the catch type
catchType
)

Declares an exception table entry.

public default CodeBuilder

Returns:

this builder
exceptionCatchAll
(Label
the try block start
start
,
Label
the try block end
end
,
Label
the exception handler start
handler
)

Declares an exception table entry catching all exceptions and errors.

public default CodeBuilder

Returns:

this builder
f2d
()

Generates an instruction to convert a float into a double.

public default CodeBuilder

Returns:

this builder
f2i
()

Generates an instruction to convert a float into an int.

public default CodeBuilder

Returns:

this builder
f2l
()

Generates an instruction to convert a float into a long.

public default CodeBuilder

Returns:

this builder
fadd
()

Generates an instruction to add two floats.

public default CodeBuilder

Returns:

this builder
faload
()

Generates an instruction to load from a float array.

public default CodeBuilder

Returns:

this builder
fastore
()

Generates an instruction to store into a float array.

public default CodeBuilder

Returns:

this builder
fcmpg
()

Generates an instruction to compare floats, producing 1 if any operand is NaN.

public default CodeBuilder

Returns:

this builder
fcmpl
()

Generates an instruction to compare floats, producing -1 if any operand is NaN.

public default CodeBuilder

Returns:

this builder
fconst_0
()

Generates an instruction pushing float constant 0 onto the operand stack.

public default CodeBuilder

Returns:

this builder
fconst_1
()

Generates an instruction pushing float constant 1 onto the operand stack.

public default CodeBuilder

Returns:

this builder
fconst_2
()

Generates an instruction pushing float constant 2 onto the operand stack.

public default CodeBuilder

Returns:

this builder
fdiv
()

Generates an instruction to divide floats.

public default CodeBuilder

Returns:

this builder
fieldAccess
(Opcode
the field access opcode
opcode
,
FieldRefEntry
the field reference
ref
)

Generates an instruction to access a field.

public default CodeBuilder

Returns:

this builder
fieldAccess
(Opcode
the field access opcode
opcode
,
ClassDesc
the class
owner
,
String
the field name
name
,
ClassDesc
the field type
type
)

Generates an instruction to access a field.

public default CodeBuilder

Returns:

this builder
fload
(int
the local variable slot
slot
)

Generates an instruction to load a float from a local variable.

public default CodeBuilder

Returns:

this builder
fmul
()

Generates an instruction to multiply floats.

public default CodeBuilder

Returns:

this builder
fneg
()

Generates an instruction to negate a float.

public default CodeBuilder

Returns:

this builder
frem
()

Generates an instruction to calculate floats remainder.

public default CodeBuilder

Returns:

this builder
freturn
()

Generates an instruction to return a float from this method.

public default CodeBuilder

Returns:

this builder
fstore
(int
the local variable slot
slot
)

Generates an instruction to store a float into a local variable.

public default CodeBuilder

Returns:

this builder
fsub
()

Generates an instruction to subtract floats.

public default CodeBuilder

Returns:

this builder
getfield
(FieldRefEntry
the field reference
ref
)

Generates an instruction to fetch field from an object.

public default CodeBuilder

Returns:

this builder
getfield
(ClassDesc
the owner class
owner
,
String
the field name
name
,
ClassDesc
the field type
type
)

Generates an instruction to fetch field from an object.

public default CodeBuilder

Returns:

this builder
getstatic
(FieldRefEntry
the field reference
ref
)

Generates an instruction to get static field from a class or interface.

public default CodeBuilder

Returns:

this builder
getstatic
(ClassDesc
the owner class
owner
,
String
the field name
name
,
ClassDesc
the field type
type
)

Generates an instruction to get static field from a class or interface.

public default CodeBuilder

Returns:

this builder
goto_
(Label
the branch target
target
)

Generates an instruction to branch always.

public default CodeBuilder

Returns:

this builder
goto_w
(Label
the branch target
target
)

Generates an instruction to branch always with wide index.

public default CodeBuilder

Returns:

this builder
i2b
()

Generates an instruction to truncate an int into the range of byte and sign-extend it.

public default CodeBuilder

Returns:

this builder
i2c
()

Generates an instruction to truncate an int into the range of char and zero-extend it.

public default CodeBuilder

Returns:

this builder
i2d
()

Generates an instruction to convert an int into a double.

public default CodeBuilder

Returns:

this builder
i2f
()

Generates an instruction to convert an int into a float.

public default CodeBuilder

Returns:

this builder
i2l
()

Generates an instruction to convert an int into a long.

public default CodeBuilder

Returns:

this builder
i2s
()

Generates an instruction to truncate an int into the range of short and sign-extend it.

public default CodeBuilder

Returns:

this builder
iadd
()

Generates an instruction to add two ints.

public default CodeBuilder

Returns:

this builder
iaload
()

Generates an instruction to load from an int array.

public default CodeBuilder

Returns:

this builder
iand
()

Generates an instruction to calculate bitwise AND of ints, also used for boolean AND.

public default CodeBuilder

Returns:

this builder
iastore
()

Generates an instruction to store into an int array.

public default CodeBuilder

Returns:

this builder
iconst_0
()

Generates an instruction pushing int constant 0 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_1
()

Generates an instruction pushing int constant 1 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_2
()

Generates an instruction pushing int constant 2 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_3
()

Generates an instruction pushing int constant 3 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_4
()

Generates an instruction pushing int constant 4 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_5
()

Generates an instruction pushing int constant 5 onto the operand stack.

public default CodeBuilder

Returns:

this builder
iconst_m1
()

Generates an instruction pushing int constant -1 onto the operand stack.

public default CodeBuilder

Returns:

this builder
idiv
()

Generates an instruction to divide ints.

public default CodeBuilder

Returns:

this builder
if_acmpeq
(Label
the branch target
target
)

Generates an instruction to branch if reference comparison operand1 == operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_acmpne
(Label
the branch target
target
)

Generates an instruction to branch if reference comparison operand1 != operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmpeq
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 == operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmpge
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 >= operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmpgt
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 > operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmple
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 <= operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmplt
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 < operand2 succeeds.

public default CodeBuilder

Returns:

this builder
if_icmpne
(Label
the branch target
target
)

Generates an instruction to branch if int comparison operand1 != operand2 succeeds.

public default CodeBuilder

Returns:

this builder
ifeq
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero == 0 succeeds.

public default CodeBuilder

Returns:

this builder
ifge
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero >= 0 succeeds.

public default CodeBuilder

Returns:

this builder
ifgt
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero > 0 succeeds.

public default CodeBuilder

Returns:

this builder
ifle
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero <= 0 succeeds.

public default CodeBuilder

Returns:

this builder
iflt
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero < 0 succeeds.

public default CodeBuilder

Returns:

this builder
ifne
(Label
the branch target
target
)

Generates an instruction to branch if int comparison with zero != 0 succeeds.

public default CodeBuilder

Returns:

this builder
ifnonnull
(Label
the branch target
target
)

Generates an instruction to branch if reference is not null.

public default CodeBuilder

Returns:

this builder
ifnull
(Label
the branch target
target
)

Generates an instruction to branch if reference is null.

public default CodeBuilder

Returns:

this builder
ifThen
(Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the if
thenHandler
)

Adds an "if-then" block that is conditional on the boolean value on top of the operand stack.

public default CodeBuilder

Returns:

this builder
ifThen
(Opcode
the operation code for a branch instruction that accepts one or two operands on the stack
opcode
,
Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the if
thenHandler
)

Adds an "if-then" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode.

public default CodeBuilder

Returns:

this builder
ifThenElse
(Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the if
thenHandler
,
Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the else
elseHandler
)

Adds an "if-then-else" block that is conditional on the boolean value on top of the operand stack.

public default CodeBuilder

Returns:

this builder
ifThenElse
(Opcode
the operation code for a branch instruction that accepts one or two operands on the stack
opcode
,
Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the if
thenHandler
,
Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the else
elseHandler
)

Adds an "if-then-else" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode.

public default CodeBuilder

Returns:

this builder
iinc
(int
the local variable slot
slot
,
int
the increment value
val
)

Generates an instruction to increment an int local variable by a constant.

public default CodeBuilder

Returns:

this builder
iload
(int
the local variable slot
slot
)

Generates an instruction to load an int from a local variable.

public default CodeBuilder

Returns:

this builder
imul
()

Generates an instruction to multiply ints.

public default CodeBuilder

Returns:

this builder
ineg
()

Generates an instruction to negate an int.

public default CodeBuilder

Returns:

this builder
instanceOf
(ClassEntry
the target type
target
)

Generates an instruction to determine if an object is of the given type, producing a boolean result on the operand stack.

public default CodeBuilder

Returns:

this builder
instanceOf
(ClassDesc
the target type
target
)

Generates an instruction to determine if an object is of the given type, producing a boolean result on the operand stack.

public default CodeBuilder

Returns:

this builder
invoke
(Opcode
the invoke opcode
opcode
,
MemberRefEntry
the interface method or method reference
ref
)

Generates an instruction to invoke a method.

public default CodeBuilder

Returns:

this builder
invoke
(Opcode
the invoke opcode
opcode
,
ClassDesc
the class
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
desc
,
boolean
whether the owner class is an interface
isInterface
)

Generates an instruction to invoke a method.

public default CodeBuilder

Returns:

this builder
invokedynamic
(InvokeDynamicEntry
the dynamic call site
ref
)

Generates an instruction to invoke a dynamically-computed call site.

public default CodeBuilder

Returns:

this builder
invokedynamic
(DynamicCallSiteDesc
the dynamic call site
ref
)

Generates an instruction to invoke a dynamically-computed call site.

public default CodeBuilder

Returns:

this builder
invokeinterface
(InterfaceMethodRefEntry
the interface method reference
ref
)

Generates an instruction to invoke an interface method.

public default CodeBuilder

Returns:

this builder
invokeinterface
(ClassDesc
the owner interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
)

Generates an instruction to invoke an interface method.

public default CodeBuilder

Returns:

this builder
invokespecial
(InterfaceMethodRefEntry
the interface method reference
ref
)

Generates an instruction to invoke an instance method in an interface; direct invocation of methods of the current class and its supertypes.

public default CodeBuilder

Returns:

this builder
invokespecial
(MethodRefEntry
the method reference
ref
)

Generates an instruction to invoke an instance method in a class; direct invocation of instance initialization methods and methods of the current class and its supertypes.

public default CodeBuilder

Returns:

this builder
invokespecial
(ClassDesc
the owner class, must not be an interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
)

Generates an instruction to invoke an instance method in a class; direct invocation of instance initialization methods and methods of the current class and its supertypes.

public default CodeBuilder

Returns:

this builder
invokespecial
(ClassDesc
the owner class or interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
,
boolean
whether the owner is an interface
isInterface
)

Generates an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes.

public default CodeBuilder

Returns:

this builder
invokestatic
(InterfaceMethodRefEntry
the interface method reference
ref
)

Generates an instruction to invoke a class (static) method of an interface.

public default CodeBuilder

Returns:

this builder
invokestatic
(MethodRefEntry
the method reference
ref
)

Generates an instruction to invoke a class (static) method of a class.

public default CodeBuilder

Returns:

this builder
invokestatic
(ClassDesc
the owner class, must not be an interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
)

Generates an instruction to invoke a class (static) method of a class.

public default CodeBuilder

Returns:

this builder
invokestatic
(ClassDesc
the owner class or interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
,
boolean
whether the owner is an interface
isInterface
)

Generates an instruction to invoke a class (static) method.

public default CodeBuilder

Returns:

this builder
invokevirtual
(MethodRefEntry
the method reference
ref
)

Generates an instruction to invoke an instance method; dispatch based on class.

public default CodeBuilder

Returns:

this builder
invokevirtual
(ClassDesc
the owner class, must not be an interface
owner
,
String
the method name
name
,
MethodTypeDesc
the method type
type
)

Generates an instruction to invoke an instance method; dispatch based on class.

public default CodeBuilder

Returns:

this builder
ior
()

Generates an instruction to calculate bitwise OR of ints, also used for boolean OR.

public default CodeBuilder

Returns:

this builder
irem
()

Generates an instruction to calculate ints remainder.

public default CodeBuilder

Returns:

this builder
ireturn
()

Generates an instruction to return an int from this method.

public default CodeBuilder

Returns:

this builder
ishl
()

Generates an instruction to shift an int left.

public default CodeBuilder

Returns:

this builder
ishr
()

Generates an instruction to shift an int right.

public default CodeBuilder

Returns:

this builder
istore
(int
the local variable slot
slot
)

Generates an instruction to store an int into a local variable.

public default CodeBuilder

Returns:

this builder
isub
()

Generates an instruction to subtract ints.

public default CodeBuilder

Returns:

this builder
iushr
()

Generates an instruction to logical shift an int right.

public default CodeBuilder

Returns:

this builder
ixor
()

Generates an instruction to calculate bitwise XOR of ints.

public default CodeBuilder

Returns:

this builder
l2d
()

Generates an instruction to convert a long into a double.

public default CodeBuilder

Returns:

this builder
l2f
()

Generates an instruction to convert a long into a float.

public default CodeBuilder

Returns:

this builder
l2i
()

Generates an instruction to convert a long into an int.

public default CodeBuilder

Returns:

this builder
labelBinding
(Label
the label
label
)

Binds a label to the current position.

public default CodeBuilder

Returns:

this builder
ladd
()

Generates an instruction to add two longs.

public default CodeBuilder

Returns:

this builder
laload
()

Generates an instruction to load from a long array.

public default CodeBuilder

Returns:

this builder
land
()

Generates an instruction to calculate bitwise AND of longs.

public default CodeBuilder

Returns:

this builder
lastore
()

Generates an instruction to store into a long array.

public default CodeBuilder

Returns:

this builder
lcmp
()

Generates an instruction to compare longs.

public default CodeBuilder

Returns:

this builder
lconst_0
()

Generates an instruction pushing long constant 0 onto the operand stack.

public default CodeBuilder

Returns:

this builder
lconst_1
()

Generates an instruction pushing long constant 1 onto the operand stack.

public default CodeBuilder

Returns:

this builder
ldc
(ConstantDesc
the constant value
value
)

Generates an instruction pushing an item from the run-time constant pool onto the operand stack.

public default CodeBuilder

Returns:

this builder
ldc
(LoadableConstantEntry
the constant value
entry
)

Generates an instruction pushing an item from the run-time constant pool onto the operand stack.

public default CodeBuilder

Returns:

this builder
ldiv
()

Generates an instruction to divide longs.

public default CodeBuilder

Returns:

this builder
lineNumber
(int
the line number
line
)

Declares a source line number beginning at the current position.

public default CodeBuilder

Returns:

this builder
lload
(int
the local variable slot
slot
)

Generates an instruction to load a long from a local variable.

public default CodeBuilder

Returns:

this builder
lmul
()

Generates an instruction to multiply longs.

public default CodeBuilder

Returns:

this builder
lneg
()

Generates an instruction to negate a long.

public default CodeBuilder

Returns:

this builder
loadConstant
(ConstantDesc
the constant value, may be null
value
)

Generates an instruction pushing a constant onto the operand stack.

public default CodeBuilder

Returns:

this builder
loadConstant
(int
the int value
value
)

Generates an instruction pushing a constant int value onto the operand stack.

public default CodeBuilder

Returns:

this builder
loadConstant
(long
the long value
value
)

Generates an instruction pushing a constant long value onto the operand stack.

public default CodeBuilder

Returns:

this builder
loadConstant
(float
the float value
value
)

Generates an instruction pushing a constant float value onto the operand stack.

public default CodeBuilder

Returns:

this builder
loadConstant
(double
the double value
value
)

Generates an instruction pushing a constant double value onto the operand stack.

public default CodeBuilder

Returns:

this builder
loadLocal
(TypeKind
the load type
tk
,
int
the local variable slot
slot
)

Generates an instruction to load a value from a local variable.

public default CodeBuilder

Returns:

this builder
localVariable
(int
the local variable slot
slot
,
Utf8Entry
the variable name
nameEntry
,
Utf8Entry
the variable descriptor
descriptorEntry
,
Label
the start scope of the variable
startScope
,
Label
the end scope of the variable
endScope
)

Declares a local variable entry.

public default CodeBuilder

Returns:

this builder
localVariable
(int
the local variable slot
slot
,
String
the variable name
name
,
ClassDesc
the variable descriptor
descriptor
,
Label
the start scope of the variable
startScope
,
Label
the end scope of the variable
endScope
)

Declares a local variable entry.

public default CodeBuilder

Returns:

this builder
localVariableType
(int
the local variable slot
slot
,
Utf8Entry
the variable name
nameEntry
,
Utf8Entry
the variable signature
signatureEntry
,
Label
the start scope of the variable
startScope
,
Label
the end scope of the variable
endScope
)

Declares a local variable type entry.

public default CodeBuilder

Returns:

this builder
localVariableType
(int
the local variable slot
slot
,
String
the variable name
name
,
Signature
the variable signature
signature
,
Label
the start scope of the variable
startScope
,
Label
the end scope of the variable
endScope
)

Declares a local variable type entry.

public default CodeBuilder

Returns:

this builder
lookupswitch
(Label
the default jump target
defaultTarget
,
List<SwitchCase>
the switch cases
cases
)

Generates an instruction to access a jump table by key match and jump.

public default CodeBuilder

Returns:

this builder
lor
()

Generates an instruction to calculate bitwise OR of longs.

public default CodeBuilder

Returns:

this builder
lrem
()

Generates an instruction to calculate longs remainder.

public default CodeBuilder

Returns:

this builder
lreturn
()

Generates an instruction to return a long from this method.

public default CodeBuilder

Returns:

this builder
lshl
()

Generates an instruction to shift a long left.

public default CodeBuilder

Returns:

this builder
lshr
()

Generates an instruction to shift a long right.

public default CodeBuilder

Returns:

this builder
lstore
(int
the local variable slot
slot
)

Generates an instruction to store a long into a local variable.

public default CodeBuilder

Returns:

this builder
lsub
()

Generates an instruction to subtract longs.

public default CodeBuilder

Returns:

this builder
lushr
()

Generates an instruction to logical shift a long right.

public default CodeBuilder

Returns:

this builder
lxor
()

Generates an instruction to calculate bitwise XOR of longs.

public default CodeBuilder

Returns:

this builder
monitorenter
()

Generates an instruction to enter monitor for an object.

public default CodeBuilder

Returns:

this builder
monitorexit
()

Generates an instruction to exit monitor for an object.

public default CodeBuilder

Returns:

this builder
multianewarray
(ClassEntry
the array type
array
,
int
the number of dimensions
dims
)

Generates an instruction to create a new multidimensional array.

public default CodeBuilder

Returns:

this builder
multianewarray
(ClassDesc
the array type
array
,
int
the number of dimensions
dims
)

Generates an instruction to create a new multidimensional array.

public default CodeBuilder

Returns:

this builder
new_
(ClassEntry
the new class type
clazz
)

Generates an instruction to create a new object.

public default CodeBuilder

Returns:

this builder
new_
(ClassDesc
the new class type
clazz
)

Generates an instruction to create a new object.

public default CodeBuilder

Returns:

this builder
newarray
(TypeKind
the primitive array type
typeKind
)

Generates an instruction to create a new array of a primitive type.

public default Label

Returns:

this builder
newBoundLabel
()

Creates a new label bound at the current position.

public Label

Returns:

a fresh unbound label
newLabel
()

Returns a fresh unbound label.

public default CodeBuilder

Returns:

this builder
nop
()

Generates a do-nothing instruction.

public int

Returns:

the local variable slot associated with the specified parameter
parameterSlot
(int
the index of the parameter
paramNo
)

Returns the local variable slot associated with the specified parameter.

public default CodeBuilder

Returns:

this builder
pop
()

Generates an instruction to pop the top operand stack value.

public default CodeBuilder

Returns:

this builder
pop2
()

Generates an instruction to pop the top one or two operand stack values.

public default CodeBuilder

Returns:

this builder
putfield
(FieldRefEntry
the field reference
ref
)

Generates an instruction to set field in an object.

public default CodeBuilder

Returns:

this builder
putfield
(ClassDesc
the owner class
owner
,
String
the field name
name
,
ClassDesc
the field type
type
)

Generates an instruction to set field in an object.

public default CodeBuilder

Returns:

this builder
putstatic
(FieldRefEntry
the field reference
ref
)

Generates an instruction to set static field in a class.

public default CodeBuilder

Returns:

this builder
putstatic
(ClassDesc
the owner class or interface
owner
,
String
the field name
name
,
ClassDesc
the field type
type
)

Generates an instruction to set static field in a class.

public int

Returns:

the local variable slot associated with the receiver
receiverSlot
()

Returns the local variable slot associated with the receiver.

public default CodeBuilder

Returns:

this builder
return_
(TypeKind
the return type
tk
)

Generates a return instruction.

public default CodeBuilder

Returns:

this builder
return_
()

Generates an instruction to return void from this method.

public default CodeBuilder

Returns:

this builder
saload
()

Generates an instruction to load from a short array.

public default CodeBuilder

Returns:

this builder
sastore
()

Generates an instruction to store into a short array.

public default CodeBuilder

Returns:

this builder
sipush
(int
the int in the range of short
s
)

Generates an instruction pushing an int in the range of short, [-32768, 32767], onto the operand stack.

public Label

Returns:

the label associated with the beginning of the current block
startLabel
()

Returns the label associated with the beginning of the current block.

public default CodeBuilder

Returns:

this builder
storeLocal
(TypeKind
the store type
tk
,
int
the local variable slot
slot
)

Generates an instruction to store a value to a local variable.

public default CodeBuilder

Returns:

this builder
swap
()

Generates an instruction to swap the top two operand stack values.

public default CodeBuilder

Returns:

this builder
tableswitch
(int
the minimum key, inclusive
low
,
int
the maximum key, inclusive
high
,
Label
the default jump target
defaultTarget
,
List<SwitchCase>
the switch cases
cases
)

Generates an instruction to access a jump table by index and jump.

public default CodeBuilder

Returns:

this builder
tableswitch
(Label
the default jump target
defaultTarget
,
List<SwitchCase>
the switch cases
cases
)

Generates an instruction to access a jump table by index and jump.

public default CodeBuilder

Returns:

this builder
transforming
(CodeTransform
the transform to apply to the code built by the handler
transform
,
Consumer<CodeBuilder>
the handler that receives a CodeBuilder to build the code
handler
)

Apply a transform to the code built by a handler, directing results to this builder.

public default CodeBuilder

Returns:

this builder
trying
(Consumer<CodeBuilder.BlockCodeBuilder>
handler that receives a BlockCodeBuilder to generate the body of the try block.
tryHandler
,
Consumer<CodeBuilder.CatchBuilder>
a handler that receives a CatchBuilder to generate bodies of catch blocks
catchesHandler
)

Adds a "try-catch" block comprising one try block and zero or more catch blocks.

Inherited from java.lang.classfile.ClassFileBuilder:
acceptconstantPooltransformwith