Interface CodeBuilder.BlockCodeBuilder
- All Superinterfaces:
ClassFileBuilder<CodeElement, CodeBuilder>, CodeBuilder, Consumer<CodeElement>
- Enclosing interface:
CodeBuilder
public static sealed interface CodeBuilder.BlockCodeBuilder extends CodeBuilder
CodeBuilder.startLabel() and CodeBuilder.endLabel() do not enclose the entire method body, but from the start to the end of the block. The location where a block of code merges back to its parent block, as represented by the breakLabel(), is expected to be reachable, either from this block or the parent block. The built code may be malformed if there is no executable code at that location.
- Since:
- 24
Nested Class Summary
Nested classes/interfaces declared in interface CodeBuilder
CodeBuilder.BlockCodeBuilder, CodeBuilder.CatchBuilder | Modifier and Type | Interface | Description |
|---|---|---|
static interface |
CodeBuilder.BlockCodeBuilder |
A builder for blocks of code. |
static interface |
CodeBuilder.CatchBuilder |
A builder to add catch blocks. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Label |
breakLabel() |
Returns the label locating where control is passed back to the parent block. |
Methods declared in interface ClassFileBuilder
accept, constantPool, transform, with | Modifier and Type | Method | Description |
|---|---|---|
default void |
accept |
Integrates the member element into the structure being built. |
ConstantPoolBuilder |
constantPool() |
Returns the constant pool builder associated with this builder. |
default CodeBuilder |
transform |
Applies a transform to a compound structure, directing results to this builder. |
CodeBuilder |
with |
Integrates the member element into the structure being built. |
Methods declared in interface CodeBuilder
aaload, aastore, aconst_null, allocateLocal, aload, anewarray, anewarray, areturn, arraylength, arrayLoad, arrayStore, astore, athrow, baload, bastore, bipush, block, branch, caload, castore, characterRange, checkcast, checkcast, conversion, d2f, d2i, d2l, dadd, daload, dastore, dcmpg, dcmpl, dconst_0, dconst_1, ddiv, dload, dmul, dneg, drem, dreturn, dstore, dsub, dup, dup_x1, dup_x2, dup2, dup2_x1, dup2_x2, endLabel, exceptionCatch, exceptionCatch, exceptionCatch, exceptionCatchAll, f2d, f2i, f2l, fadd, faload, fastore, fcmpg, fcmpl, fconst_0, fconst_1, fconst_2, fdiv, fieldAccess, fieldAccess, fload, fmul, fneg, frem, freturn, fstore, fsub, getfield, getfield, getstatic, getstatic, goto_, goto_w, i2b, i2c, i2d, i2f, i2l, i2s, iadd, iaload, iand, iastore, iconst_0, iconst_1, iconst_2, iconst_3, iconst_4, iconst_5, iconst_m1, idiv, if_acmpeq, if_acmpne, if_icmpeq, if_icmpge, if_icmpgt, if_icmple, if_icmplt, if_icmpne, ifeq, ifge, ifgt, ifle, iflt, ifne, ifnonnull, ifnull, ifThen, ifThen, ifThenElse, ifThenElse, iinc, iload, imul, ineg, instanceOf, instanceOf, invoke, invoke, invokedynamic, invokedynamic, invokeinterface, invokeinterface, invokespecial, invokespecial, invokespecial, invokespecial, invokestatic, invokestatic, invokestatic, invokestatic, invokevirtual, invokevirtual, ior, irem, ireturn, ishl, ishr, istore, isub, iushr, ixor, l2d, l2f, l2i, labelBinding, ladd, laload, land, lastore, lcmp, lconst_0, lconst_1, ldc, ldc, ldiv, lineNumber, lload, lmul, lneg, loadConstant, loadConstant, loadConstant, loadConstant, loadConstant, loadLocal, localVariable, localVariable, localVariableType, localVariableType, lookupswitch, lor, lrem, lreturn, lshl, lshr, lstore, lsub, lushr, lxor, monitorenter, monitorexit, multianewarray, multianewarray, new_, new_, newarray, newBoundLabel, newLabel, nop, parameterSlot, pop, pop2, putfield, putfield, putstatic, putstatic, receiverSlot, return_, return_, saload, sastore, sipush, startLabel, storeLocal, swap, tableswitch, tableswitch, transforming, trying | Modifier and Type | Method | Description |
|---|---|---|
default CodeBuilder |
aaload() |
Generates an instruction to load from a reference array. |
default CodeBuilder |
aastore() |
Generates an instruction to store into a reference array. |
default CodeBuilder |
aconst_null() |
Generates an instruction pushing the null object reference onto the operand stack. |
int |
allocateLocal |
Returns the local variable slot of a fresh local variable. |
default CodeBuilder |
aload |
Generates an instruction to load a reference from a local variable. |
default CodeBuilder |
anewarray |
Generates an instruction to create a new array of reference. |
default CodeBuilder |
anewarray |
Generates an instruction to create a new array of reference. |
default CodeBuilder |
areturn() |
Generates an instruction to return a reference from this method. |
default CodeBuilder |
arraylength() |
Generates an instruction to get the length of an array. |
default CodeBuilder |
arrayLoad |
Generates an instruction to load from an array. |
default CodeBuilder |
arrayStore |
Generates an instruction to store into an array. |
default CodeBuilder |
astore |
Generates an instruction to store a reference into a local variable. |
default CodeBuilder |
athrow() |
Generates an instruction to throw an exception or error. |
default CodeBuilder |
baload() |
|
default CodeBuilder |
bastore() |
|
default CodeBuilder |
bipush |
|
default CodeBuilder |
block |
Adds a lexical block to the method being built. |
default CodeBuilder |
branch |
Generates a branch instruction. |
default CodeBuilder |
caload() |
Generates an instruction to load from a char array. |
default CodeBuilder |
castore() |
Generates an instruction to store into a char array. |
default CodeBuilder |
characterRange |
Declares a character range entry. |
default CodeBuilder |
checkcast |
Generates an instruction to check whether an object is of the given type, throwing a ClassCastException if the check fails. |
default CodeBuilder |
checkcast |
Generates an instruction to check whether an object is of the given type, throwing a ClassCastException if the check fails. |
default CodeBuilder |
conversion |
Generates instruction(s) to convert fromType to toType. |
default CodeBuilder |
d2f() |
|
default CodeBuilder |
d2i() |
|
default CodeBuilder |
d2l() |
|
default CodeBuilder |
dadd() |
Generates an instruction to add two doubles. |
default CodeBuilder |
daload() |
Generates an instruction to load from a double array. |
default CodeBuilder |
dastore() |
Generates an instruction to store into a double array. |
default CodeBuilder |
dcmpg() |
|
default CodeBuilder |
dcmpl() |
|
default CodeBuilder |
dconst_0() |
Generates an instruction pushing double constant 0 onto the operand stack. |
default CodeBuilder |
dconst_1() |
Generates an instruction pushing double constant 1 onto the operand stack. |
default CodeBuilder |
ddiv() |
Generates an instruction to divide doubles. |
default CodeBuilder |
dload |
Generates an instruction to load a double from a local variable. |
default CodeBuilder |
dmul() |
Generates an instruction to multiply doubles. |
default CodeBuilder |
dneg() |
Generates an instruction to negate a double. |
default CodeBuilder |
drem() |
Generates an instruction to calculate double remainder. |
default CodeBuilder |
dreturn() |
Generates an instruction to return a double from this method. |
default CodeBuilder |
dstore |
Generates an instruction to store a double into a local variable. |
default CodeBuilder |
dsub() |
Generates an instruction to subtract doubles. |
default CodeBuilder |
dup() |
Generates an instruction to duplicate the top operand stack value. |
default CodeBuilder |
dup_x1() |
Generates an instruction to duplicate the top operand stack value and insert two values down. |
default CodeBuilder |
dup_x2() |
Generates an instruction to duplicate the top operand stack value and insert two or three values down. |
default CodeBuilder |
dup2() |
Generates an instruction to duplicate the top one or two operand stack value. |
default CodeBuilder |
dup2_x1() |
Generates an instruction to duplicate the top one or two operand stack values and insert two or three values down. |
default CodeBuilder |
dup2_x2() |
Generates an instruction to duplicate the top one or two operand stack values and insert two, three, or four values down. |
Label |
endLabel() |
Returns the label associated with the end of the current block. |
default CodeBuilder |
exceptionCatch |
Declares an exception table entry. |
default CodeBuilder |
exceptionCatch |
Declares an exception table entry. |
default CodeBuilder |
exceptionCatch |
Declares an exception table entry. |
default CodeBuilder |
exceptionCatchAll |
Declares an exception table entry catching all exceptions and errors. |
default CodeBuilder |
f2d() |
|
default CodeBuilder |
f2i() |
|
default CodeBuilder |
f2l() |
|
default CodeBuilder |
fadd() |
Generates an instruction to add two floats. |
default CodeBuilder |
faload() |
Generates an instruction to load from a float array. |
default CodeBuilder |
fastore() |
Generates an instruction to store into a float array. |
default CodeBuilder |
fcmpg() |
|
default CodeBuilder |
fcmpl() |
|
default CodeBuilder |
fconst_0() |
Generates an instruction pushing float constant 0 onto the operand stack. |
default CodeBuilder |
fconst_1() |
Generates an instruction pushing float constant 1 onto the operand stack. |
default CodeBuilder |
fconst_2() |
Generates an instruction pushing float constant 2 onto the operand stack. |
default CodeBuilder |
fdiv() |
Generates an instruction to divide floats. |
default CodeBuilder |
fieldAccess |
Generates an instruction to access a field. |
default CodeBuilder |
fieldAccess |
Generates an instruction to access a field. |
default CodeBuilder |
fload |
Generates an instruction to load a float from a local variable. |
default CodeBuilder |
fmul() |
Generates an instruction to multiply floats. |
default CodeBuilder |
fneg() |
Generates an instruction to negate a float. |
default CodeBuilder |
frem() |
Generates an instruction to calculate floats remainder. |
default CodeBuilder |
freturn() |
Generates an instruction to return a float from this method. |
default CodeBuilder |
fstore |
Generates an instruction to store a float into a local variable. |
default CodeBuilder |
fsub() |
Generates an instruction to subtract floats. |
default CodeBuilder |
getfield |
Generates an instruction to fetch field from an object. |
default CodeBuilder |
getfield |
Generates an instruction to fetch field from an object. |
default CodeBuilder |
getstatic |
Generates an instruction to get static field from a class or interface. |
default CodeBuilder |
getstatic |
Generates an instruction to get static field from a class or interface. |
default CodeBuilder |
goto_ |
Generates an instruction to branch always. |
default CodeBuilder |
goto_w |
Generates an instruction to branch always with wide index. |
default CodeBuilder |
i2b() |
|
default CodeBuilder |
i2c() |
|
default CodeBuilder |
i2d() |
|
default CodeBuilder |
i2f() |
|
default CodeBuilder |
i2l() |
|
default CodeBuilder |
i2s() |
|
default CodeBuilder |
iadd() |
Generates an instruction to add two ints. |
default CodeBuilder |
iaload() |
Generates an instruction to load from an int array. |
default CodeBuilder |
iand() |
|
default CodeBuilder |
iastore() |
Generates an instruction to store into an int array. |
default CodeBuilder |
iconst_0() |
Generates an instruction pushing int constant 0 onto the operand stack. |
default CodeBuilder |
iconst_1() |
Generates an instruction pushing int constant 1 onto the operand stack. |
default CodeBuilder |
iconst_2() |
Generates an instruction pushing int constant 2 onto the operand stack. |
default CodeBuilder |
iconst_3() |
Generates an instruction pushing int constant 3 onto the operand stack. |
default CodeBuilder |
iconst_4() |
Generates an instruction pushing int constant 4 onto the operand stack. |
default CodeBuilder |
iconst_5() |
Generates an instruction pushing int constant 5 onto the operand stack. |
default CodeBuilder |
iconst_m1() |
Generates an instruction pushing int constant -1 onto the operand stack. |
default CodeBuilder |
idiv() |
Generates an instruction to divide ints. |
default CodeBuilder |
if_acmpeq |
Generates an instruction to branch if reference comparison operand1 == operand2 succeeds. |
default CodeBuilder |
if_acmpne |
Generates an instruction to branch if reference comparison operand1 != operand2 succeeds. |
default CodeBuilder |
if_icmpeq |
Generates an instruction to branch if int comparison operand1 == operand2 succeeds. |
default CodeBuilder |
if_icmpge |
Generates an instruction to branch if int comparison operand1 >= operand2 succeeds. |
default CodeBuilder |
if_icmpgt |
Generates an instruction to branch if int comparison operand1 > operand2 succeeds. |
default CodeBuilder |
if_icmple |
Generates an instruction to branch if int comparison operand1 <= operand2 succeeds. |
default CodeBuilder |
if_icmplt |
Generates an instruction to branch if int comparison operand1 < operand2 succeeds. |
default CodeBuilder |
if_icmpne |
Generates an instruction to branch if int comparison operand1 != operand2 succeeds. |
default CodeBuilder |
ifeq |
Generates an instruction to branch if int comparison with zero == 0 succeeds. |
default CodeBuilder |
ifge |
Generates an instruction to branch if int comparison with zero >= 0 succeeds. |
default CodeBuilder |
ifgt |
Generates an instruction to branch if int comparison with zero > 0 succeeds. |
default CodeBuilder |
ifle |
Generates an instruction to branch if int comparison with zero <= 0 succeeds. |
default CodeBuilder |
iflt |
Generates an instruction to branch if int comparison with zero < 0 succeeds. |
default CodeBuilder |
ifne |
Generates an instruction to branch if int comparison with zero != 0 succeeds. |
default CodeBuilder |
ifnonnull |
Generates an instruction to branch if reference is not null. |
default CodeBuilder |
ifnull |
Generates an instruction to branch if reference is null. |
default CodeBuilder |
ifThen |
Adds an "if-then" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode. |
default CodeBuilder |
ifThen |
Adds an "if-then" block that is conditional on the boolean value on top of the operand stack. |
default CodeBuilder |
ifThenElse |
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. |
default CodeBuilder |
ifThenElse |
Adds an "if-then-else" block that is conditional on the boolean value on top of the operand stack. |
default CodeBuilder |
iinc |
Generates an instruction to increment an int local variable by a constant. |
default CodeBuilder |
iload |
Generates an instruction to load an int from a local variable. |
default CodeBuilder |
imul() |
Generates an instruction to multiply ints. |
default CodeBuilder |
ineg() |
Generates an instruction to negate an int. |
default CodeBuilder |
instanceOf |
Generates an instruction to determine if an object is of the given type, producing a boolean result on the operand stack. |
default CodeBuilder |
instanceOf |
Generates an instruction to determine if an object is of the given type, producing a boolean result on the operand stack. |
default CodeBuilder |
invoke |
Generates an instruction to invoke a method. |
default CodeBuilder |
invoke |
Generates an instruction to invoke a method. |
default CodeBuilder |
invokedynamic |
Generates an instruction to invoke a dynamically-computed call site. |
default CodeBuilder |
invokedynamic |
Generates an instruction to invoke a dynamically-computed call site. |
default CodeBuilder |
invokeinterface |
Generates an instruction to invoke an interface method. |
default CodeBuilder |
invokeinterface |
Generates an instruction to invoke an interface method. |
default CodeBuilder |
invokespecial |
Generates an instruction to invoke an instance method in an interface; direct invocation of methods of the current class and its supertypes. |
default CodeBuilder |
invokespecial |
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. |
default CodeBuilder |
invokespecial |
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. |
default CodeBuilder |
invokespecial |
Generates an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes. |
default CodeBuilder |
invokestatic |
Generates an instruction to invoke a class (static) method of an interface. |
default CodeBuilder |
invokestatic |
Generates an instruction to invoke a class (static) method of a class. |
default CodeBuilder |
invokestatic |
Generates an instruction to invoke a class (static) method of a class. |
default CodeBuilder |
invokestatic |
Generates an instruction to invoke a class (static) method. |
default CodeBuilder |
invokevirtual |
Generates an instruction to invoke an instance method; dispatch based on class. |
default CodeBuilder |
invokevirtual |
Generates an instruction to invoke an instance method; dispatch based on class. |
default CodeBuilder |
ior() |
|
default CodeBuilder |
irem() |
Generates an instruction to calculate ints remainder. |
default CodeBuilder |
ireturn() |
Generates an instruction to return an int from this method. |
default CodeBuilder |
ishl() |
Generates an instruction to shift an int left. |
default CodeBuilder |
ishr() |
Generates an instruction to shift an int right. |
default CodeBuilder |
istore |
Generates an instruction to store an int into a local variable. |
default CodeBuilder |
isub() |
Generates an instruction to subtract ints. |
default CodeBuilder |
iushr() |
Generates an instruction to logical shift an int right. |
default CodeBuilder |
ixor() |
Generates an instruction to calculate bitwise XOR of ints. |
default CodeBuilder |
l2d() |
|
default CodeBuilder |
l2f() |
|
default CodeBuilder |
l2i() |
|
default CodeBuilder |
labelBinding |
Binds a label to the current position. |
default CodeBuilder |
ladd() |
Generates an instruction to add two longs. |
default CodeBuilder |
laload() |
Generates an instruction to load from a long array. |
default CodeBuilder |
land() |
Generates an instruction to calculate bitwise AND of longs. |
default CodeBuilder |
lastore() |
Generates an instruction to store into a long array. |
default CodeBuilder |
lcmp() |
Generates an instruction to compare longs. |
default CodeBuilder |
lconst_0() |
Generates an instruction pushing long constant 0 onto the operand stack. |
default CodeBuilder |
lconst_1() |
Generates an instruction pushing long constant 1 onto the operand stack. |
default CodeBuilder |
ldc |
Generates an instruction pushing an item from the run-time constant pool onto the operand stack. |
default CodeBuilder |
ldc |
Generates an instruction pushing an item from the run-time constant pool onto the operand stack. |
default CodeBuilder |
ldiv() |
Generates an instruction to divide longs. |
default CodeBuilder |
lineNumber |
Declares a source line number beginning at the current position. |
default CodeBuilder |
lload |
Generates an instruction to load a long from a local variable. |
default CodeBuilder |
lmul() |
Generates an instruction to multiply longs. |
default CodeBuilder |
lneg() |
Generates an instruction to negate a long. |
default CodeBuilder |
loadConstant |
Generates an instruction pushing a constant double value onto the operand stack. |
default CodeBuilder |
loadConstant |
Generates an instruction pushing a constant float value onto the operand stack. |
default CodeBuilder |
loadConstant |
Generates an instruction pushing a constant int value onto the operand stack. |
default CodeBuilder |
loadConstant |
Generates an instruction pushing a constant long value onto the operand stack. |
default CodeBuilder |
loadConstant |
Generates an instruction pushing a constant onto the operand stack. |
default CodeBuilder |
loadLocal |
Generates an instruction to load a value from a local variable. |
default CodeBuilder |
localVariable |
Declares a local variable entry. |
default CodeBuilder |
localVariable |
Declares a local variable entry. |
default CodeBuilder |
localVariableType |
Declares a local variable type entry. |
default CodeBuilder |
localVariableType |
Declares a local variable type entry. |
default CodeBuilder |
lookupswitch |
Generates an instruction to access a jump table by key match and jump. |
default CodeBuilder |
lor() |
Generates an instruction to calculate bitwise OR of longs. |
default CodeBuilder |
lrem() |
Generates an instruction to calculate longs remainder. |
default CodeBuilder |
lreturn() |
Generates an instruction to return a long from this method. |
default CodeBuilder |
lshl() |
Generates an instruction to shift a long left. |
default CodeBuilder |
lshr() |
Generates an instruction to shift a long right. |
default CodeBuilder |
lstore |
Generates an instruction to store a long into a local variable. |
default CodeBuilder |
lsub() |
Generates an instruction to subtract longs. |
default CodeBuilder |
lushr() |
Generates an instruction to logical shift a long right. |
default CodeBuilder |
lxor() |
Generates an instruction to calculate bitwise XOR of longs. |
default CodeBuilder |
monitorenter() |
Generates an instruction to enter monitor for an object. |
default CodeBuilder |
monitorexit() |
Generates an instruction to exit monitor for an object. |
default CodeBuilder |
multianewarray |
Generates an instruction to create a new multidimensional array. |
default CodeBuilder |
multianewarray |
Generates an instruction to create a new multidimensional array. |
default CodeBuilder |
new_ |
Generates an instruction to create a new object. |
default CodeBuilder |
new_ |
Generates an instruction to create a new object. |
default CodeBuilder |
newarray |
Generates an instruction to create a new array of a primitive type. |
default Label |
newBoundLabel() |
Creates a new label bound at the current position. |
Label |
newLabel() |
Returns a fresh unbound label. |
default CodeBuilder |
nop() |
Generates a do-nothing instruction. |
int |
parameterSlot |
Returns the local variable slot associated with the specified parameter. |
default CodeBuilder |
pop() |
Generates an instruction to pop the top operand stack value. |
default CodeBuilder |
pop2() |
Generates an instruction to pop the top one or two operand stack values. |
default CodeBuilder |
putfield |
Generates an instruction to set field in an object. |
default CodeBuilder |
putfield |
Generates an instruction to set field in an object. |
default CodeBuilder |
putstatic |
Generates an instruction to set static field in a class. |
default CodeBuilder |
putstatic |
Generates an instruction to set static field in a class. |
int |
receiverSlot() |
Returns the local variable slot associated with the receiver. |
default CodeBuilder |
return_() |
Generates an instruction to return void from this method. |
default CodeBuilder |
return_ |
Generates a return instruction. |
default CodeBuilder |
saload() |
Generates an instruction to load from a short array. |
default CodeBuilder |
sastore() |
Generates an instruction to store into a short array. |
default CodeBuilder |
sipush |
|
Label |
startLabel() |
Returns the label associated with the beginning of the current block. |
default CodeBuilder |
storeLocal |
Generates an instruction to store a value to a local variable. |
default CodeBuilder |
swap() |
Generates an instruction to swap the top two operand stack values. |
default CodeBuilder |
tableswitch |
Generates an instruction to access a jump table by index and jump. |
default CodeBuilder |
tableswitch |
Generates an instruction to access a jump table by index and jump. |
default CodeBuilder |
transforming |
Apply a transform to the code built by a handler, directing results to this builder. |
default CodeBuilder |
trying |
Adds a "try-catch" block comprising one try block and zero or more catch blocks. |
Methods declared in interface Consumer
andThen | Modifier and Type | Method | Description |
|---|---|---|
default Consumer |
andThen |
Returns a composed Consumer that performs, in sequence, this operation followed by the after operation. |
Method Details
breakLabel
Label breakLabel()
If the last instruction in this block does not lead to the break label, Class-File API may append instructions to target the "break" label to the built block.
- Returns:
- the label locating where control is passed back to the parent block
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.