- All Superinterfaces:
ClassFileBuilderPREVIEW<CodeElementPREVIEW,
,CodeBuilderPREVIEW> Consumer<CodeElementPREVIEW>
- All Known Subinterfaces:
CodeBuilder.BlockCodeBuilderPREVIEW
CodeBuilder
is a preview API of the Java platform.
MethodBuilder.withCode(Consumer)
PREVIEW or to code transforms. The elements of a
code can be specified abstractly, by passing a CodeElement
PREVIEW to ClassFileBuilder.with(ClassFileElement)
PREVIEW or concretely by calling the various withXxx
methods.- Since:
- 22
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Preview.A builder for blocks of code.static interface
Preview.A builder to add catch blocks. -
Method Summary
Modifier and TypeMethodDescriptiondefault CodeBuilderPREVIEW
aaload()
Generate an instruction to load a reference from an arraydefault CodeBuilderPREVIEW
aastore()
Generate an instruction to store into a reference arraydefault CodeBuilderPREVIEW
Generate an instruction pushing the null object reference onto the operand stackint
allocateLocal
(TypeKindPREVIEW typeKind) Returns the local variable slot of a fresh local variable.default CodeBuilderPREVIEW
aload
(int slot) Generate an instruction to load a reference from a local variabledefault CodeBuilderPREVIEW
anewarray
(ClassEntryPREVIEW classEntry) Generate an instruction to create a new array of referencedefault CodeBuilderPREVIEW
Generate an instruction to create a new array of referencedefault CodeBuilderPREVIEW
areturn()
Generate an instruction to return a reference from the methoddefault CodeBuilderPREVIEW
Generate an instruction to get length of an arraydefault CodeBuilderPREVIEW
Generate an instruction to load from an arraydefault CodeBuilderPREVIEW
Generate an instruction to store into an arraydefault CodeBuilderPREVIEW
astore
(int slot) Generate an instruction to store a reference into a local variabledefault CodeBuilderPREVIEW
athrow()
Generate an instruction to throw an exception or errordefault CodeBuilderPREVIEW
baload()
Generate an instruction to load a byte from a arraydefault CodeBuilderPREVIEW
bastore()
Generate an instruction to store into a byte arraydefault CodeBuilderPREVIEW
bipush
(int b) Generate an instruction pushing a byte onto the operand stackdefault CodeBuilderPREVIEW
block
(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> handler) Add a lexical block to the method being built.default CodeBuilderPREVIEW
branchInstruction
(OpcodePREVIEW op, LabelPREVIEW target) Generate a branch instructiondefault CodeBuilderPREVIEW
caload()
Generate an instruction to load a char from an arraydefault CodeBuilderPREVIEW
castore()
Generate an instruction to store into a char arraydefault CodeBuilderPREVIEW
characterRange
(LabelPREVIEW startScope, LabelPREVIEW endScope, int characterRangeStart, int characterRangeEnd, int flags) Declare a character range entrydefault CodeBuilderPREVIEW
checkcast
(ClassEntryPREVIEW type) Generate an instruction to check whether an object is of the given typedefault CodeBuilderPREVIEW
Generate an instruction to check whether an object is of the given typedefault CodeBuilderPREVIEW
constantInstruction
(OpcodePREVIEW opcode, ConstantDesc value) Generate an instruction pushing a constant onto the operand stackdefault CodeBuilderPREVIEW
constantInstruction
(ConstantDesc value) Generate an instruction pushing a constant onto the operand stackdefault CodeBuilderPREVIEW
convertInstruction
(TypeKindPREVIEW fromType, TypeKindPREVIEW toType) Generate a type converting instructiondefault CodeBuilderPREVIEW
d2f()
Generate an instruction to convert a double into a floatdefault CodeBuilderPREVIEW
d2i()
Generate an instruction to convert a double into an intdefault CodeBuilderPREVIEW
d2l()
Generate an instruction to convert a double into a longdefault CodeBuilderPREVIEW
dadd()
Generate an instruction to add a doubledefault CodeBuilderPREVIEW
daload()
Generate an instruction to load a double from an arraydefault CodeBuilderPREVIEW
dastore()
Generate an instruction to store into a double arraydefault CodeBuilderPREVIEW
dcmpg()
Generate an instruction to add a doubledefault CodeBuilderPREVIEW
dcmpl()
Generate an instruction to compare doublesdefault CodeBuilderPREVIEW
dconst_0()
Generate an instruction pushing double constant 0 onto the operand stackdefault CodeBuilderPREVIEW
dconst_1()
Generate an instruction pushing double constant 1 onto the operand stackdefault CodeBuilderPREVIEW
ddiv()
Generate an instruction to divide doublesdefault CodeBuilderPREVIEW
dload
(int slot) Generate an instruction to load a double from a local variabledefault CodeBuilderPREVIEW
dmul()
Generate an instruction to multiply doublesdefault CodeBuilderPREVIEW
dneg()
Generate an instruction to negate a doubledefault CodeBuilderPREVIEW
drem()
Generate an instruction to calculate double remainderdefault CodeBuilderPREVIEW
dreturn()
Generate an instruction to return a double from the methoddefault CodeBuilderPREVIEW
dstore
(int slot) Generate an instruction to store a double into a local variabledefault CodeBuilderPREVIEW
dsub()
Generate an instruction to subtract doublesdefault CodeBuilderPREVIEW
dup()
Generate an instruction to duplicate the top operand stack valuedefault CodeBuilderPREVIEW
dup_x1()
Generate an instruction to duplicate the top operand stack value and insert two values downdefault CodeBuilderPREVIEW
dup_x2()
Generate an instruction to duplicate the top operand stack value and insert two or three values downdefault CodeBuilderPREVIEW
dup2()
Generate an instruction to duplicate the top one or two operand stack valuedefault CodeBuilderPREVIEW
dup2_x1()
Generate an instruction to duplicate the top one or two operand stack values and insert two or three values downdefault CodeBuilderPREVIEW
dup2_x2()
Generate an instruction to duplicate the top one or two operand stack values and insert two, three, or four values downendLabel()
Returns the label associated with the end of the current block.default CodeBuilderPREVIEW
exceptionCatch
(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler, ClassEntryPREVIEW catchType) Declare an exception table entrydefault CodeBuilderPREVIEW
Declare an exception table entrydefault CodeBuilderPREVIEW
exceptionCatch
(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler, Optional<ClassEntryPREVIEW> catchType) Declare an exception table entrydefault CodeBuilderPREVIEW
Declare an exception table entry catching all exceptions and errorsdefault CodeBuilderPREVIEW
f2d()
Generate an instruction to convert a float into a doubledefault CodeBuilderPREVIEW
f2i()
Generate an instruction to convert a float into an intdefault CodeBuilderPREVIEW
f2l()
Generate an instruction to convert a float into a longdefault CodeBuilderPREVIEW
fadd()
Generate an instruction to add a floatdefault CodeBuilderPREVIEW
faload()
Generate an instruction to load a float from an arraydefault CodeBuilderPREVIEW
fastore()
Generate an instruction to store into a float arraydefault CodeBuilderPREVIEW
fcmpg()
Generate an instruction to compare floatsdefault CodeBuilderPREVIEW
fcmpl()
Generate an instruction to compare floatsdefault CodeBuilderPREVIEW
fconst_0()
Generate an instruction pushing float constant 0 onto the operand stackdefault CodeBuilderPREVIEW
fconst_1()
Generate an instruction pushing float constant 1 onto the operand stackdefault CodeBuilderPREVIEW
fconst_2()
Generate an instruction pushing float constant 2 onto the operand stackdefault CodeBuilderPREVIEW
fdiv()
Generate an instruction to divide floatsdefault CodeBuilderPREVIEW
fieldInstruction
(OpcodePREVIEW opcode, FieldRefEntryPREVIEW ref) Generate an instruction to access a fielddefault CodeBuilderPREVIEW
Generate an instruction to access a fielddefault CodeBuilderPREVIEW
fload
(int slot) Generate an instruction to load a float from a local variabledefault CodeBuilderPREVIEW
fmul()
Generate an instruction to multiply floatsdefault CodeBuilderPREVIEW
fneg()
Generate an instruction to negate a floatdefault CodeBuilderPREVIEW
frem()
Generate an instruction to calculate floats remainderdefault CodeBuilderPREVIEW
freturn()
Generate an instruction to return a float from the methoddefault CodeBuilderPREVIEW
fstore
(int slot) Generate an instruction to store a float into a local variabledefault CodeBuilderPREVIEW
fsub()
Generate an instruction to subtract floatsdefault CodeBuilderPREVIEW
Generate an instruction to fetch field from an objectdefault CodeBuilderPREVIEW
Generate an instruction to fetch field from an objectdefault CodeBuilderPREVIEW
Generate an instruction to get static field from a classdefault CodeBuilderPREVIEW
Generate an instruction to get static field from a classdefault CodeBuilderPREVIEW
Generate an instruction to branch alwaysdefault CodeBuilderPREVIEW
Generate an instruction to branch always with wide indexdefault CodeBuilderPREVIEW
i2b()
Generate an instruction to convert an int into a bytedefault CodeBuilderPREVIEW
i2c()
Generate an instruction to convert an int into a chardefault CodeBuilderPREVIEW
i2d()
Generate an instruction to convert an int into a doubledefault CodeBuilderPREVIEW
i2f()
Generate an instruction to convert an int into a floatdefault CodeBuilderPREVIEW
i2l()
Generate an instruction to convert an int into a longdefault CodeBuilderPREVIEW
i2s()
Generate an instruction to convert an int into a shortdefault CodeBuilderPREVIEW
iadd()
Generate an instruction to add an intdefault CodeBuilderPREVIEW
iaload()
Generate an instruction to load a int from an arraydefault CodeBuilderPREVIEW
iand()
Generate an instruction to calculate boolean AND of intsdefault CodeBuilderPREVIEW
iastore()
Generate an instruction to store into an int arraydefault CodeBuilderPREVIEW
iconst_0()
Generate an instruction pushing int constant 0 onto the operand stackdefault CodeBuilderPREVIEW
iconst_1()
Generate an instruction pushing int constant 1 onto the operand stackdefault CodeBuilderPREVIEW
iconst_2()
Generate an instruction pushing int constant 2 onto the operand stackdefault CodeBuilderPREVIEW
iconst_3()
Generate an instruction pushing int constant 3 onto the operand stackdefault CodeBuilderPREVIEW
iconst_4()
Generate an instruction pushing int constant 4 onto the operand stackdefault CodeBuilderPREVIEW
iconst_5()
Generate an instruction pushing int constant 5 onto the operand stackdefault CodeBuilderPREVIEW
Generate an instruction pushing int constant -1 onto the operand stackdefault CodeBuilderPREVIEW
idiv()
Generate an instruction to divide intsdefault CodeBuilderPREVIEW
Generate an instruction to branch if reference comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if reference comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison succeedsdefault CodeBuilderPREVIEW
if_nonnull
(LabelPREVIEW target) Generate an instruction to branch if reference is not nulldefault CodeBuilderPREVIEW
Generate an instruction to branch if reference is nulldefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilderPREVIEW
Add an "if-then" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode.default CodeBuilderPREVIEW
ifThen
(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler) Add an "if-then" block that is conditional on the boolean value on top of the operand stack.default CodeBuilderPREVIEW
ifThenElse
(OpcodePREVIEW opcode, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> elseHandler) Add 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 CodeBuilderPREVIEW
ifThenElse
(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> elseHandler) Add an "if-then-else" block that is conditional on the boolean value on top of the operand stack.default CodeBuilderPREVIEW
iinc
(int slot, int val) Generate an instruction to increment a local variable by a constantdefault CodeBuilderPREVIEW
iload
(int slot) Generate an instruction to load an int from a local variabledefault CodeBuilderPREVIEW
imul()
Generate an instruction to multiply intsdefault CodeBuilderPREVIEW
incrementInstruction
(int slot, int val) Generate an instruction to increment a local variable by a constantdefault CodeBuilderPREVIEW
ineg()
Generate an instruction to negate an intdefault CodeBuilderPREVIEW
instanceof_
(ClassEntryPREVIEW target) Generate an instruction to determine if an object is of the given typedefault CodeBuilderPREVIEW
instanceof_
(ClassDesc target) Generate an instruction to determine if an object is of the given typedefault CodeBuilderPREVIEW
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilderPREVIEW
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilderPREVIEW
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilderPREVIEW
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilderPREVIEW
invokeInstruction
(OpcodePREVIEW opcode, MemberRefEntryPREVIEW ref) Generate an instruction to invoke a method or constructordefault CodeBuilderPREVIEW
invokeInstruction
(OpcodePREVIEW opcode, ClassDesc owner, String name, MethodTypeDesc desc, boolean isInterface) Generate an instruction to invoke a method or constructordefault CodeBuilderPREVIEW
Generate an instruction to invoke an interface methoddefault CodeBuilderPREVIEW
invokeinterface
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke an interface methoddefault CodeBuilderPREVIEW
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilderPREVIEW
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilderPREVIEW
invokespecial
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilderPREVIEW
invokespecial
(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilderPREVIEW
Generate an instruction to invoke a class (static) methoddefault CodeBuilderPREVIEW
Generate an instruction to invoke a class (static) methoddefault CodeBuilderPREVIEW
invokestatic
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke a class (static) methoddefault CodeBuilderPREVIEW
invokestatic
(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) Generate an instruction to invoke a class (static) methoddefault CodeBuilderPREVIEW
Generate an instruction to invoke an instance method; dispatch based on classdefault CodeBuilderPREVIEW
invokevirtual
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke an instance method; dispatch based on classdefault CodeBuilderPREVIEW
ior()
Generate an instruction to calculate boolean OR of intsdefault CodeBuilderPREVIEW
irem()
Generate an instruction to calculate ints remainderdefault CodeBuilderPREVIEW
ireturn()
Generate an instruction to return an int from the methoddefault CodeBuilderPREVIEW
ishl()
Generate an instruction to shift an int leftdefault CodeBuilderPREVIEW
ishr()
Generate an instruction to shift an int rightdefault CodeBuilderPREVIEW
istore
(int slot) Generate an instruction to store an int into a local variabledefault CodeBuilderPREVIEW
isub()
Generate an instruction to subtract intsdefault CodeBuilderPREVIEW
iushr()
Generate an instruction to logical shift an int rightdefault CodeBuilderPREVIEW
ixor()
Generate an instruction to calculate boolean XOR of intsdefault CodeBuilderPREVIEW
l2d()
Generate an instruction to convert a long into a doubledefault CodeBuilderPREVIEW
l2f()
Generate an instruction to convert a long into a floatdefault CodeBuilderPREVIEW
l2i()
Generate an instruction to convert a long into an intdefault CodeBuilderPREVIEW
labelBinding
(LabelPREVIEW label) Bind label with current positiondefault CodeBuilderPREVIEW
ladd()
Generate an instruction to add a longdefault CodeBuilderPREVIEW
laload()
Generate an instruction to load a long from an arraydefault CodeBuilderPREVIEW
land()
Generate an instruction to calculate boolean AND of longsdefault CodeBuilderPREVIEW
lastore()
Generate an instruction to store into a long arraydefault CodeBuilderPREVIEW
lcmp()
Generate an instruction to compare longsdefault CodeBuilderPREVIEW
lconst_0()
Generate an instruction pushing long constant 0 onto the operand stackdefault CodeBuilderPREVIEW
lconst_1()
Generate an instruction pushing long constant 1 onto the operand stackdefault CodeBuilderPREVIEW
ldc
(LoadableConstantEntryPREVIEW entry) Generate an instruction pushing an item from the run-time constant pool onto the operand stackdefault CodeBuilderPREVIEW
ldc
(ConstantDesc value) Generate an instruction pushing an item from the run-time constant pool onto the operand stackdefault CodeBuilderPREVIEW
ldiv()
Generate an instruction to divide longsdefault CodeBuilderPREVIEW
lineNumber
(int line) Declare a source line number of the current builder positiondefault CodeBuilderPREVIEW
lload
(int slot) Generate an instruction to load a long from a local variabledefault CodeBuilderPREVIEW
lmul()
Generate an instruction to multiply longsdefault CodeBuilderPREVIEW
lneg()
Generate an instruction to negate a longdefault CodeBuilderPREVIEW
loadInstruction
(TypeKindPREVIEW tk, int slot) Generate an instruction to load a value from a local variabledefault CodeBuilderPREVIEW
localVariable
(int slot, Utf8EntryPREVIEW nameEntry, Utf8EntryPREVIEW descriptorEntry, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable entrydefault CodeBuilderPREVIEW
localVariable
(int slot, String name, ClassDesc descriptor, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable entrydefault CodeBuilderPREVIEW
localVariableType
(int slot, Utf8EntryPREVIEW nameEntry, Utf8EntryPREVIEW signatureEntry, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable type entrydefault CodeBuilderPREVIEW
localVariableType
(int slot, String name, SignaturePREVIEW signature, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable type entrydefault CodeBuilderPREVIEW
lookupswitch
(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by key match and jumpdefault CodeBuilderPREVIEW
lookupSwitchInstruction
(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by key match and jumpdefault CodeBuilderPREVIEW
lor()
Generate an instruction to calculate boolean OR of longsdefault CodeBuilderPREVIEW
lrem()
Generate an instruction to calculate longs remainderdefault CodeBuilderPREVIEW
lreturn()
Generate an instruction to return a long from the methoddefault CodeBuilderPREVIEW
lshl()
Generate an instruction to shift a long leftdefault CodeBuilderPREVIEW
lshr()
Generate an instruction to shift a long rightdefault CodeBuilderPREVIEW
lstore
(int slot) Generate an instruction to store a long into a local variabledefault CodeBuilderPREVIEW
lsub()
Generate an instruction to subtract longsdefault CodeBuilderPREVIEW
lushr()
Generate an instruction to logical shift a long leftdefault CodeBuilderPREVIEW
lxor()
Generate an instruction to calculate boolean XOR of longsdefault CodeBuilderPREVIEW
Generate an instruction to enter monitor for an objectdefault CodeBuilderPREVIEW
Generate an instruction to exit monitor for an objectdefault CodeBuilderPREVIEW
monitorInstruction
(OpcodePREVIEW opcode) Generate a monitor instructiondefault CodeBuilderPREVIEW
multianewarray
(ClassEntryPREVIEW array, int dims) Generate an instruction to create a new multidimensional arraydefault CodeBuilderPREVIEW
multianewarray
(ClassDesc array, int dims) Generate an instruction to create a new multidimensional arraydefault CodeBuilderPREVIEW
new_
(ClassEntryPREVIEW clazz) Generate an instruction to create a new objectdefault CodeBuilderPREVIEW
Generate an instruction to create a new objectdefault CodeBuilderPREVIEW
Generate an instruction to create a new array of a primitive typeCreate new label bound with current positionnewLabel()
Returns a fresh unbound label.default CodeBuilderPREVIEW
newMultidimensionalArrayInstruction
(int dimensions, ClassEntryPREVIEW type) Generate an instruction to create a new multidimensional arraydefault CodeBuilderPREVIEW
newMultidimensionalArrayInstruction
(int dimensions, ClassDesc type) Generate an instruction to create a new multidimensional arraydefault CodeBuilderPREVIEW
Generate an instruction to create a new objectdefault CodeBuilderPREVIEW
Generate an instruction to create a new objectdefault CodeBuilderPREVIEW
newPrimitiveArrayInstruction
(TypeKindPREVIEW typeKind) Generate an instruction to create a new array of a primitive typedefault CodeBuilderPREVIEW
Generate an instruction to create a new array of referencedefault CodeBuilderPREVIEW
Generate an instruction to create a new array of referencedefault CodeBuilderPREVIEW
nop()
Generate a do nothing instructiondefault CodeBuilderPREVIEW
Generate a do nothing instructiondefault CodeBuilderPREVIEW
operatorInstruction
(OpcodePREVIEW opcode) Generate an operator instructionoriginal()
int
parameterSlot
(int paramNo) Returns the local variable slot associated with the specified parameter.default CodeBuilderPREVIEW
pop()
Generate an instruction to pop the top operand stack valuedefault CodeBuilderPREVIEW
pop2()
Generate an instruction to pop the top one or two operand stack valuesdefault CodeBuilderPREVIEW
Generate an instruction to set field in an objectdefault CodeBuilderPREVIEW
Generate an instruction to set field in an objectdefault CodeBuilderPREVIEW
Generate an instruction to set static field in a classdefault CodeBuilderPREVIEW
Generate an instruction to set static field in a classint
Returns the local variable slot associated with the receiver.default CodeBuilderPREVIEW
return_()
Generate an instruction to return void from the methoddefault CodeBuilderPREVIEW
Generate return instructiondefault CodeBuilderPREVIEW
saload()
Generate an instruction to load a short from an arraydefault CodeBuilderPREVIEW
sastore()
Generate an instruction to store into a short arraydefault CodeBuilderPREVIEW
sipush
(int s) Generate an instruction pushing a short onto the operand stackdefault CodeBuilderPREVIEW
stackInstruction
(OpcodePREVIEW opcode) Generate a stack manipulating instructionReturns the label associated with the beginning of the current block.default CodeBuilderPREVIEW
storeInstruction
(TypeKindPREVIEW tk, int slot) Generate an instruction to store a value to a local variabledefault CodeBuilderPREVIEW
swap()
Generate an instruction to swap the top two operand stack valuesdefault CodeBuilderPREVIEW
tableswitch
(int low, int high, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by index and jumpdefault CodeBuilderPREVIEW
tableswitch
(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by index and jumpdefault CodeBuilderPREVIEW
tableSwitchInstruction
(int lowValue, int highValue, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by index and jumpdefault CodeBuilderPREVIEW
Generate an instruction to throw an exception or errordefault CodeBuilderPREVIEW
transforming
(CodeTransformPREVIEW transform, Consumer<CodeBuilderPREVIEW> handler) Apply a transform to the code built by a handler, directing results to this builder.default CodeBuilderPREVIEW
trying
(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> tryHandler, Consumer<CodeBuilder.CatchBuilderPREVIEW> catchesHandler) Adds a "try-catch" block comprising one try block and zero or more catch blocks.default CodeBuilderPREVIEW
typeCheckInstruction
(OpcodePREVIEW opcode, ClassEntryPREVIEW type) Generate a type checking instructiondefault CodeBuilderPREVIEW
typeCheckInstruction
(OpcodePREVIEW opcode, ClassDesc type) Generate a type checking instructionMethods declared in interface java.lang.classfile.ClassFileBuilderPREVIEW
accept, canWriteDirect, constantPool, transform, with
-
Method Details
-
original
-
newLabel
-
startLabel
Returns the label associated with the beginning of the current block. If the current CodeBuilderPREVIEW is not a "block" builder, such as those provided byblock(Consumer)
orifThenElse(Consumer, Consumer)
, the current block will be the entire method body.- Returns:
- the label associated with the beginning of the current block
-
endLabel
Returns the label associated with the end of the current block. If the current CodeBuilderPREVIEW is not a "block" builder, such as those provided byblock(Consumer)
orifThenElse(Consumer, Consumer)
, the current block will be the entire method body.- Returns:
- the label associated with the end of the current block
-
receiverSlot
int receiverSlot()Returns the local variable slot associated with the receiver..- Returns:
- the local variable slot associated with the receiver
- Throws:
IllegalStateException
- if this is not a static method
-
parameterSlot
int parameterSlot(int paramNo) Returns the local variable slot associated with the specified parameter.. The returned value is adjusted for the receiver slot (if the method is an instance method) and for the requirement thatlong
anddouble
values require two slots.- Parameters:
paramNo
- the index of the parameter- Returns:
- the local variable slot associated with the specified parameter
-
allocateLocal
Returns the local variable slot of a fresh local variable. This method makes reasonable efforts to determine which slots are in use and which are not. When transforming a method, fresh locals begin at themaxLocals
of the original method. For a method being built directly, fresh locals begin after the last parameter slot.If the current code builder is a "block" code builder provided by
block(Consumer)
,ifThen(Consumer)
, orifThenElse(Consumer, Consumer)
, at the end of the block, locals are reset to their value at the beginning of the block.- Parameters:
typeKind
- the type of the local variable- Returns:
- the local variable slot of a fresh local variable
-
transforming
default CodeBuilderPREVIEW transforming(CodeTransformPREVIEW transform, Consumer<CodeBuilderPREVIEW> handler) Apply a transform to the code built by a handler, directing results to this builder.- Parameters:
transform
- the transform to apply to the code built by the handlerhandler
- the handler that receives a CodeBuilderPREVIEW to build the code.- Returns:
- this builder
-
block
Add a lexical block to the method being built.Within this block, the
startLabel()
andendLabel()
correspond to the start and end of the block, and theCodeBuilder.BlockCodeBuilder.breakLabel()
PREVIEW also corresponds to the end of the block.- Parameters:
handler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of the lexical block.- Returns:
- this builder
-
ifThen
Add an "if-then" block that is conditional on the boolean value on top of the operand stack.The
CodeBuilder.BlockCodeBuilder.breakLabel()
PREVIEW for the "then" block corresponds to the end of that block.- Parameters:
thenHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theif
- Returns:
- this builder
-
ifThen
default CodeBuilderPREVIEW ifThen(OpcodePREVIEW opcode, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler) Add an "if-then" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode.The
CodeBuilder.BlockCodeBuilder.breakLabel()
PREVIEW for the "then" block corresponds to the end of that block.- Parameters:
opcode
- the operation code for a branch instructions that accepts one or two operands on the stackthenHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theif
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the operation code is not for a branch instruction that accepts one or two operands
-
ifThenElse
default CodeBuilderPREVIEW ifThenElse(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> elseHandler) Add an "if-then-else" block that is conditional on the boolean value on top of the operand stack.The
CodeBuilder.BlockCodeBuilder.breakLabel()
PREVIEW for each block corresponds to the end of the "else" block.- Parameters:
thenHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theif
elseHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theelse
- Returns:
- this builder
-
ifThenElse
default CodeBuilderPREVIEW ifThenElse(OpcodePREVIEW opcode, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> thenHandler, Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> elseHandler) Add an "if-then-else" block that is conditional on the value(s) on top of the operand stack in accordance with the given opcode.The
CodeBuilder.BlockCodeBuilder.breakLabel()
PREVIEW for each block corresponds to the end of the "else" block.- Parameters:
opcode
- the operation code for a branch instructions that accepts one or two operands on the stackthenHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theif
elseHandler
- handler that receives a CodeBuilder.BlockCodeBuilderPREVIEW to generate the body of theelse
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the operation code is not for a branch instruction that accepts one or two operands
-
trying
default CodeBuilderPREVIEW trying(Consumer<CodeBuilder.BlockCodeBuilderPREVIEW> tryHandler, Consumer<CodeBuilder.CatchBuilderPREVIEW> catchesHandler) Adds a "try-catch" block comprising one try block and zero or more catch blocks. Exceptions thrown by instructions in the try block may be caught by catch blocks.- Parameters:
tryHandler
- handler that receives a CodeBuilderPREVIEW to generate the body of the try block.catchesHandler
- a handler that receives a CodeBuilder.CatchBuilderPREVIEW to generate bodies of catch blocks.- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the try block is empty.- See Also:
-
loadInstruction
Generate an instruction to load a value from a local variable- Parameters:
tk
- the load typeslot
- the local variable slot- Returns:
- this builder
-
storeInstruction
Generate an instruction to store a value to a local variable- Parameters:
tk
- the store typeslot
- the local variable slot- Returns:
- this builder
-
incrementInstruction
Generate an instruction to increment a local variable by a constant- Parameters:
slot
- the local variable slotval
- the increment value- Returns:
- this builder
-
branchInstruction
-
lookupSwitchInstruction
default CodeBuilderPREVIEW lookupSwitchInstruction(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by key match and jump- Parameters:
defaultTarget
- the default jump targetcases
- the switch cases- Returns:
- this builder
-
tableSwitchInstruction
default CodeBuilderPREVIEW tableSwitchInstruction(int lowValue, int highValue, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by index and jump- Parameters:
lowValue
- the low key valuehighValue
- the high key valuedefaultTarget
- the default jump targetcases
- the switch cases- Returns:
- this builder
-
returnInstruction
Generate return instruction- Parameters:
tk
- the return type- Returns:
- this builder
-
throwInstruction
Generate an instruction to throw an exception or error- Returns:
- this builder
-
fieldInstruction
Generate an instruction to access a field- Parameters:
opcode
- the field access opcoderef
- the field reference- Returns:
- this builder
- See Also:
-
fieldInstruction
-
invokeInstruction
Generate an instruction to invoke a method or constructor- Parameters:
opcode
- the invoke opcoderef
- the interface method or method reference- Returns:
- this builder
- See Also:
-
invokeInstruction
default CodeBuilderPREVIEW invokeInstruction(OpcodePREVIEW opcode, ClassDesc owner, String name, MethodTypeDesc desc, boolean isInterface) Generate an instruction to invoke a method or constructor- Parameters:
opcode
- the invoke opcodeowner
- the classname
- the method namedesc
- the method typeisInterface
- the interface method invocation indication- Returns:
- this builder
- See Also:
-
invokeDynamicInstruction
Generate an instruction to invoke a dynamically-computed call site- Parameters:
ref
- the dynamic call site- Returns:
- this builder
-
invokeDynamicInstruction
Generate an instruction to invoke a dynamically-computed call site- Parameters:
desc
- the dynamic call site- Returns:
- this builder
-
newObjectInstruction
Generate an instruction to create a new object- Parameters:
type
- the object type- Returns:
- this builder
-
newObjectInstruction
Generate an instruction to create a new object- Parameters:
type
- the object type- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftype
represents a primitive type
-
newPrimitiveArrayInstruction
Generate an instruction to create a new array of a primitive type- Parameters:
typeKind
- the primitive component type- Returns:
- this builder
-
newReferenceArrayInstruction
Generate an instruction to create a new array of reference- Parameters:
type
- the component type- Returns:
- this builder
-
newReferenceArrayInstruction
Generate an instruction to create a new array of reference- Parameters:
type
- the component type- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftype
represents a primitive type
-
newMultidimensionalArrayInstruction
default CodeBuilderPREVIEW newMultidimensionalArrayInstruction(int dimensions, ClassEntryPREVIEW type) Generate an instruction to create a new multidimensional array- Parameters:
dimensions
- the number of dimensionstype
- the array type- Returns:
- this builder
-
newMultidimensionalArrayInstruction
Generate an instruction to create a new multidimensional array- Parameters:
dimensions
- the number of dimensionstype
- the array type- Returns:
- this builder
-
arrayLoadInstruction
Generate an instruction to load from an array- Parameters:
tk
- the array element type- Returns:
- this builder
-
arrayStoreInstruction
Generate an instruction to store into an array- Parameters:
tk
- the array element type- Returns:
- this builder
-
typeCheckInstruction
Generate a type checking instruction- Parameters:
opcode
- the type check instruction opcodetype
- the type- Returns:
- this builder
- See Also:
-
typeCheckInstruction
Generate a type checking instruction- Parameters:
opcode
- the type check instruction opcodetype
- the type- Returns:
- this builder
- See Also:
-
convertInstruction
-
stackInstruction
Generate a stack manipulating instruction- Parameters:
opcode
- the stack instruction opcode- Returns:
- this builder
- See Also:
-
operatorInstruction
Generate an operator instruction- Parameters:
opcode
- the operator instruction opcode- Returns:
- this builder
- See Also:
-
constantInstruction
Generate an instruction pushing a constant onto the operand stack- Parameters:
opcode
- the constant instruction opcodevalue
- the constant value- Returns:
- this builder
- See Also:
-
constantInstruction
Generate an instruction pushing a constant onto the operand stack- Parameters:
value
- the constant value- Returns:
- this builder
-
monitorInstruction
Generate a monitor instruction- Parameters:
opcode
- the monitor instruction opcode- Returns:
- this builder
- See Also:
-
nopInstruction
-
nop
-
newBoundLabel
-
labelBinding
Bind label with current position- Parameters:
label
- the label- Returns:
- this builder
-
lineNumber
Declare a source line number of the current builder position- Parameters:
line
- the line number- Returns:
- this builder
-
exceptionCatch
default CodeBuilderPREVIEW exceptionCatch(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler, ClassEntryPREVIEW catchType) Declare an exception table entry- Parameters:
start
- the try block startend
- the try block endhandler
- the exception handler startcatchType
- the catch type or null to catch all exceptions and errors- Returns:
- this builder
-
exceptionCatch
default CodeBuilderPREVIEW exceptionCatch(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler, Optional<ClassEntryPREVIEW> catchType) Declare an exception table entry- Parameters:
start
- the try block startend
- the try block endhandler
- the exception handler startcatchType
- the optional catch type, empty to catch all exceptions and errors- Returns:
- this builder
-
exceptionCatch
default CodeBuilderPREVIEW exceptionCatch(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler, ClassDesc catchType) Declare an exception table entry- Parameters:
start
- the try block startend
- the try block endhandler
- the exception handler startcatchType
- the catch type- Returns:
- this builder
-
exceptionCatchAll
-
characterRange
default CodeBuilderPREVIEW characterRange(LabelPREVIEW startScope, LabelPREVIEW endScope, int characterRangeStart, int characterRangeEnd, int flags) Declare a character range entry- Parameters:
startScope
- the start scope of the character rangeendScope
- the end scope of the character rangecharacterRangeStart
- the encoded start of the character range region (inclusive)characterRangeEnd
- the encoded end of the character range region (exclusive)flags
- the flags word, indicating the kind of range- Returns:
- this builder
-
localVariable
default CodeBuilderPREVIEW localVariable(int slot, Utf8EntryPREVIEW nameEntry, Utf8EntryPREVIEW descriptorEntry, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable entry- Parameters:
slot
- the local variable slotnameEntry
- the variable namedescriptorEntry
- the variable descriptorstartScope
- the start scope of the variableendScope
- the end scope of the variable- Returns:
- this builder
-
localVariable
default CodeBuilderPREVIEW localVariable(int slot, String name, ClassDesc descriptor, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable entry- Parameters:
slot
- the local variable slotname
- the variable namedescriptor
- the variable descriptorstartScope
- the start scope of the variableendScope
- the end scope of the variable- Returns:
- this builder
-
localVariableType
default CodeBuilderPREVIEW localVariableType(int slot, Utf8EntryPREVIEW nameEntry, Utf8EntryPREVIEW signatureEntry, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable type entry- Parameters:
slot
- the local variable slotnameEntry
- the variable namesignatureEntry
- the variable signaturestartScope
- the start scope of the variableendScope
- the end scope of the variable- Returns:
- this builder
-
localVariableType
default CodeBuilderPREVIEW localVariableType(int slot, String name, SignaturePREVIEW signature, LabelPREVIEW startScope, LabelPREVIEW endScope) Declare a local variable type entry- Parameters:
slot
- the local variable slotname
- the variable namesignature
- the variable signaturestartScope
- the start scope of the variableendScope
- the end scope of the variable- Returns:
- this builder
-
aconst_null
Generate an instruction pushing the null object reference onto the operand stack- Returns:
- this builder
-
aaload
Generate an instruction to load a reference from an array- Returns:
- this builder
-
aastore
Generate an instruction to store into a reference array- Returns:
- this builder
-
aload
Generate an instruction to load a reference from a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
anewarray
Generate an instruction to create a new array of reference- Parameters:
classEntry
- the component type- Returns:
- this builder
-
anewarray
Generate an instruction to create a new array of reference- Parameters:
className
- the component type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifclassName
represents a primitive type
-
areturn
Generate an instruction to return a reference from the method- Returns:
- this builder
-
arraylength
Generate an instruction to get length of an array- Returns:
- this builder
-
astore
Generate an instruction to store a reference into a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
athrow
Generate an instruction to throw an exception or error- Returns:
- this builder
-
baload
Generate an instruction to load a byte from a array- Returns:
- this builder
-
bastore
Generate an instruction to store into a byte array- Returns:
- this builder
-
bipush
Generate an instruction pushing a byte onto the operand stack- Parameters:
b
- the byte- Returns:
- this builder
-
caload
Generate an instruction to load a char from an array- Returns:
- this builder
-
castore
Generate an instruction to store into a char array- Returns:
- this builder
-
checkcast
Generate an instruction to check whether an object is of the given type- Parameters:
type
- the object type- Returns:
- this builder
-
checkcast
Generate an instruction to check whether an object is of the given type- Parameters:
type
- the object type- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftype
represents a primitive type
-
d2f
Generate an instruction to convert a double into a float- Returns:
- this builder
-
d2i
Generate an instruction to convert a double into an int- Returns:
- this builder
-
d2l
Generate an instruction to convert a double into a long- Returns:
- this builder
-
dadd
-
daload
Generate an instruction to load a double from an array- Returns:
- this builder
-
dastore
Generate an instruction to store into a double array- Returns:
- this builder
-
dcmpg
-
dcmpl
-
dconst_0
Generate an instruction pushing double constant 0 onto the operand stack- Returns:
- this builder
-
dconst_1
Generate an instruction pushing double constant 1 onto the operand stack- Returns:
- this builder
-
ddiv
-
dload
Generate an instruction to load a double from a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
dmul
-
dneg
-
drem
Generate an instruction to calculate double remainder- Returns:
- this builder
-
dreturn
Generate an instruction to return a double from the method- Returns:
- this builder
-
dstore
Generate an instruction to store a double into a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
dsub
-
dup
Generate an instruction to duplicate the top operand stack value- Returns:
- this builder
-
dup2
Generate an instruction to duplicate the top one or two operand stack value- Returns:
- this builder
-
dup2_x1
Generate an instruction to duplicate the top one or two operand stack values and insert two or three values down- Returns:
- this builder
-
dup2_x2
Generate an instruction to duplicate the top one or two operand stack values and insert two, three, or four values down- Returns:
- this builder
-
dup_x1
Generate an instruction to duplicate the top operand stack value and insert two values down- Returns:
- this builder
-
dup_x2
Generate an instruction to duplicate the top operand stack value and insert two or three values down- Returns:
- this builder
-
f2d
Generate an instruction to convert a float into a double- Returns:
- this builder
-
f2i
Generate an instruction to convert a float into an int- Returns:
- this builder
-
f2l
Generate an instruction to convert a float into a long- Returns:
- this builder
-
fadd
-
faload
Generate an instruction to load a float from an array- Returns:
- this builder
-
fastore
Generate an instruction to store into a float array- Returns:
- this builder
-
fcmpg
-
fcmpl
-
fconst_0
Generate an instruction pushing float constant 0 onto the operand stack- Returns:
- this builder
-
fconst_1
Generate an instruction pushing float constant 1 onto the operand stack- Returns:
- this builder
-
fconst_2
Generate an instruction pushing float constant 2 onto the operand stack- Returns:
- this builder
-
fdiv
-
fload
Generate an instruction to load a float from a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
fmul
-
fneg
-
frem
Generate an instruction to calculate floats remainder- Returns:
- this builder
-
freturn
Generate an instruction to return a float from the method- Returns:
- this builder
-
fstore
Generate an instruction to store a float into a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
fsub
-
getfield
Generate an instruction to fetch field from an object- Parameters:
ref
- the field reference- Returns:
- this builder
-
getfield
Generate an instruction to fetch field from an object- Parameters:
owner
- the owner classname
- the field nametype
- the field type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
getstatic
Generate an instruction to get static field from a class- Parameters:
ref
- the field reference- Returns:
- this builder
-
getstatic
Generate an instruction to get static field from a class- Parameters:
owner
- the owner classname
- the field nametype
- the field type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
goto_
Generate an instruction to branch always- Parameters:
target
- the branch target- Returns:
- this builder
-
goto_w
Generate an instruction to branch always with wide index- Parameters:
target
- the branch target- Returns:
- this builder
-
i2b
Generate an instruction to convert an int into a byte- Returns:
- this builder
-
i2c
Generate an instruction to convert an int into a char- Returns:
- this builder
-
i2d
Generate an instruction to convert an int into a double- Returns:
- this builder
-
i2f
Generate an instruction to convert an int into a float- Returns:
- this builder
-
i2l
Generate an instruction to convert an int into a long- Returns:
- this builder
-
i2s
Generate an instruction to convert an int into a short- Returns:
- this builder
-
iadd
-
iaload
Generate an instruction to load a int from an array- Returns:
- this builder
-
iand
Generate an instruction to calculate boolean AND of ints- Returns:
- this builder
-
iastore
Generate an instruction to store into an int array- Returns:
- this builder
-
iconst_0
Generate an instruction pushing int constant 0 onto the operand stack- Returns:
- this builder
-
iconst_1
Generate an instruction pushing int constant 1 onto the operand stack- Returns:
- this builder
-
iconst_2
Generate an instruction pushing int constant 2 onto the operand stack- Returns:
- this builder
-
iconst_3
Generate an instruction pushing int constant 3 onto the operand stack- Returns:
- this builder
-
iconst_4
Generate an instruction pushing int constant 4 onto the operand stack- Returns:
- this builder
-
iconst_5
Generate an instruction pushing int constant 5 onto the operand stack- Returns:
- this builder
-
iconst_m1
Generate an instruction pushing int constant -1 onto the operand stack- Returns:
- this builder
-
idiv
-
if_acmpeq
Generate an instruction to branch if reference comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_acmpne
Generate an instruction to branch if reference comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmpeq
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmpge
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmpgt
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmple
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmplt
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_icmpne
Generate an instruction to branch if int comparison succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
if_nonnull
Generate an instruction to branch if reference is not null- Parameters:
target
- the branch target- Returns:
- this builder
-
if_null
Generate an instruction to branch if reference is null- Parameters:
target
- the branch target- Returns:
- this builder
-
ifeq
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
ifge
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
ifgt
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
ifle
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
iflt
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
ifne
Generate an instruction to branch if int comparison with zero succeeds- Parameters:
target
- the branch target- Returns:
- this builder
-
iinc
Generate an instruction to increment a local variable by a constant- Parameters:
slot
- the local variable slotval
- the increment value- Returns:
- this builder
-
iload
Generate an instruction to load an int from a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
imul
-
ineg
-
instanceof_
Generate an instruction to determine if an object is of the given type- Parameters:
target
- the target type- Returns:
- this builder
-
instanceof_
Generate an instruction to determine if an object is of the given type- Parameters:
target
- the target type- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftarget
represents a primitive type
-
invokedynamic
Generate an instruction to invoke a dynamically-computed call site- Parameters:
ref
- the dynamic call site- Returns:
- this builder
-
invokedynamic
Generate an instruction to invoke a dynamically-computed call site- Parameters:
ref
- the dynamic call site- Returns:
- this builder
-
invokeinterface
Generate an instruction to invoke an interface method- Parameters:
ref
- the interface method reference- Returns:
- this builder
-
invokeinterface
Generate an instruction to invoke an interface method- Parameters:
owner
- the owner classname
- the method nametype
- the method type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
invokespecial
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes- Parameters:
ref
- the interface method reference- Returns:
- this builder
-
invokespecial
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes- Parameters:
ref
- the method reference- Returns:
- this builder
-
invokespecial
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes- Parameters:
owner
- the owner classname
- the method nametype
- the method type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
invokespecial
default CodeBuilderPREVIEW invokespecial(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypes- Parameters:
owner
- the owner classname
- the method nametype
- the method typeisInterface
- the interface method invocation indication- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
invokestatic
Generate an instruction to invoke a class (static) method- Parameters:
ref
- the interface method reference- Returns:
- this builder
-
invokestatic
Generate an instruction to invoke a class (static) method- Parameters:
ref
- the method reference- Returns:
- this builder
-
invokestatic
Generate an instruction to invoke a class (static) method- Parameters:
owner
- the owner classname
- the method nametype
- the method type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
invokestatic
default CodeBuilderPREVIEW invokestatic(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) Generate an instruction to invoke a class (static) method- Parameters:
owner
- the owner classname
- the method nametype
- the method typeisInterface
- the interface method invocation indication- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
invokevirtual
Generate an instruction to invoke an instance method; dispatch based on class- Parameters:
ref
- the method reference- Returns:
- this builder
-
invokevirtual
Generate an instruction to invoke an instance method; dispatch based on class- Parameters:
owner
- the owner classname
- the method nametype
- the method type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
ior
Generate an instruction to calculate boolean OR of ints- Returns:
- this builder
-
irem
Generate an instruction to calculate ints remainder- Returns:
- this builder
-
ireturn
Generate an instruction to return an int from the method- Returns:
- this builder
-
ishl
Generate an instruction to shift an int left- Returns:
- this builder
-
ishr
Generate an instruction to shift an int right- Returns:
- this builder
-
istore
Generate an instruction to store an int into a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
isub
-
iushr
Generate an instruction to logical shift an int right- Returns:
- this builder
-
ixor
Generate an instruction to calculate boolean XOR of ints- Returns:
- this builder
-
lookupswitch
Generate an instruction to access a jump table by key match and jump- Parameters:
defaultTarget
- the default jump targetcases
- the switch cases- Returns:
- this builder
-
l2d
Generate an instruction to convert a long into a double- Returns:
- this builder
-
l2f
Generate an instruction to convert a long into a float- Returns:
- this builder
-
l2i
Generate an instruction to convert a long into an int- Returns:
- this builder
-
ladd
-
laload
Generate an instruction to load a long from an array- Returns:
- this builder
-
land
Generate an instruction to calculate boolean AND of longs- Returns:
- this builder
-
lastore
Generate an instruction to store into a long array- Returns:
- this builder
-
lcmp
-
lconst_0
Generate an instruction pushing long constant 0 onto the operand stack- Returns:
- this builder
-
lconst_1
Generate an instruction pushing long constant 1 onto the operand stack- Returns:
- this builder
-
ldc
Generate an instruction pushing an item from the run-time constant pool onto the operand stack- Parameters:
value
- the constant value- Returns:
- this builder
-
ldc
Generate an instruction pushing an item from the run-time constant pool onto the operand stack- Parameters:
entry
- the constant value- Returns:
- this builder
-
ldiv
-
lload
Generate an instruction to load a long from a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
lmul
-
lneg
-
lor
Generate an instruction to calculate boolean OR of longs- Returns:
- this builder
-
lrem
Generate an instruction to calculate longs remainder- Returns:
- this builder
-
lreturn
Generate an instruction to return a long from the method- Returns:
- this builder
-
lshl
Generate an instruction to shift a long left- Returns:
- this builder
-
lshr
Generate an instruction to shift a long right- Returns:
- this builder
-
lstore
Generate an instruction to store a long into a local variable- Parameters:
slot
- the local variable slot- Returns:
- this builder
-
lsub
-
lushr
Generate an instruction to logical shift a long left- Returns:
- this builder
-
lxor
Generate an instruction to calculate boolean XOR of longs- Returns:
- this builder
-
monitorenter
Generate an instruction to enter monitor for an object- Returns:
- this builder
-
monitorexit
Generate an instruction to exit monitor for an object- Returns:
- this builder
-
multianewarray
Generate an instruction to create a new multidimensional array- Parameters:
array
- the array typedims
- the number of dimensions- Returns:
- this builder
-
multianewarray
Generate an instruction to create a new multidimensional array- Parameters:
array
- the array typedims
- the number of dimensions- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifarray
represents a primitive type
-
new_
Generate an instruction to create a new object- Parameters:
clazz
- the new class type- Returns:
- this builder
-
new_
Generate an instruction to create a new object- Parameters:
clazz
- the new class type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifclazz
represents a primitive type
-
newarray
Generate an instruction to create a new array of a primitive type- Parameters:
typeKind
- the primitive array type- Returns:
- this builder
-
pop
Generate an instruction to pop the top operand stack value- Returns:
- this builder
-
pop2
Generate an instruction to pop the top one or two operand stack values- Returns:
- this builder
-
putfield
Generate an instruction to set field in an object- Parameters:
ref
- the field reference- Returns:
- this builder
-
putfield
Generate an instruction to set field in an object- Parameters:
owner
- the owner classname
- the field nametype
- the field type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
putstatic
Generate an instruction to set static field in a class- Parameters:
ref
- the field reference- Returns:
- this builder
-
putstatic
Generate an instruction to set static field in a class- Parameters:
owner
- the owner classname
- the field nametype
- the field type- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifowner
represents a primitive type
-
return_
Generate an instruction to return void from the method- Returns:
- this builder
-
saload
Generate an instruction to load a short from an array- Returns:
- this builder
-
sastore
Generate an instruction to store into a short array- Returns:
- this builder
-
sipush
Generate an instruction pushing a short onto the operand stack- Parameters:
s
- the short- Returns:
- this builder
-
swap
Generate an instruction to swap the top two operand stack values- Returns:
- this builder
-
tableswitch
default CodeBuilderPREVIEW tableswitch(int low, int high, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases) Generate an instruction to access a jump table by index and jump- Parameters:
low
- the low key valuehigh
- the high key valuedefaultTarget
- the default jump targetcases
- the switch cases- Returns:
- this builder
-
tableswitch
Generate an instruction to access a jump table by index and jump- Parameters:
defaultTarget
- the default jump targetcases
- the switch cases- Returns:
- this builder
-
CodeBuilder
when preview features are enabled.