Interface CodeBuilder
- All Superinterfaces:
ClassFileBuilder<CodeElement, CodeBuilder>
,Consumer<CodeElement>
- All Known Subinterfaces:
CodeBuilder.BlockCodeBuilder
MethodBuilder.withCode(Consumer)
or to code transforms. The elements of a
code can be specified abstractly, by passing a CodeElement
to ClassFileBuilder.with(ClassFileElement)
or concretely by calling the various withXxx
methods.
Instruction Factories
CodeBuilder
provides convenience methods to create instructions (See
JVMS 6.5 Instructions) by their mnemonic, taking necessary operands.
- Instructions that encode their operands in their opcode, such as
aload_<n>
, share their factories with their generic version likeaload
. Note that some constant instructions, such asiconst_1
, do not have generic versions, and thus have their own factories. - Instructions that accept wide operands, such as
ldc2_w
orwide
, share their factories with their regular version likeldc(java.lang.constant.ConstantDesc)
. Note thatgoto_w
has its own factory to avoid short jumps. - The
goto
,instanceof
,new
, andreturn
instructions' factories are namedgoto_
,instanceOf
,new_
, andreturn_
respectively, due to clashes with keywords in the Java programming language. - Factories are not provided for instructions
jsr
,jsr_w
,ret
, andwide ret
, which cannot appear in class files with major version 51 or higher. (JVMS 4.9.1)
- Since:
- 24
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A builder for blocks of code.static interface
A builder to add catch blocks. -
Method Summary
Modifier and TypeMethodDescriptiondefault CodeBuilder
aaload()
Generate an instruction to load a reference from an arraydefault CodeBuilder
aastore()
Generate an instruction to store into a reference arraydefault CodeBuilder
Generate an instruction pushing the null object reference onto the operand stackint
allocateLocal
(TypeKind typeKind) Returns the local variable slot of a fresh local variable.default CodeBuilder
aload
(int slot) Generate an instruction to load a reference from a local variabledefault CodeBuilder
anewarray
(ClassEntry classEntry) Generate an instruction to create a new array of referencedefault CodeBuilder
Generate an instruction to create a new array of referencedefault CodeBuilder
areturn()
Generate an instruction to return a reference from the methoddefault CodeBuilder
Generate an instruction to get length of an arraydefault CodeBuilder
Generate an instruction to load from an arraydefault CodeBuilder
arrayStore
(TypeKind tk) Generate an instruction to store into an arraydefault CodeBuilder
astore
(int slot) Generate an instruction to store a reference into a local variabledefault CodeBuilder
athrow()
Generate an instruction to throw an exception or errordefault CodeBuilder
baload()
Generate an instruction to load a byte from a arraydefault CodeBuilder
bastore()
Generate an instruction to store into a byte arraydefault CodeBuilder
bipush
(int b) Generate an instruction pushing an int in the range of byte onto the operand stack.default CodeBuilder
block
(Consumer<CodeBuilder.BlockCodeBuilder> handler) Add a lexical block to the method being built.default CodeBuilder
Generate a branch instructiondefault CodeBuilder
caload()
Generate an instruction to load a char from an arraydefault CodeBuilder
castore()
Generate an instruction to store into a char arraydefault CodeBuilder
characterRange
(Label startScope, Label endScope, int characterRangeStart, int characterRangeEnd, int flags) Declare a character range entrydefault CodeBuilder
checkcast
(ClassEntry type) Generate an instruction to check whether an object is of the given typedefault CodeBuilder
Generate an instruction to check whether an object is of the given typedefault CodeBuilder
conversion
(TypeKind fromType, TypeKind toType) Generate instruction(s) to convertfromType
totoType
default CodeBuilder
d2f()
Generate an instruction to convert a double into a floatdefault CodeBuilder
d2i()
Generate an instruction to convert a double into an intdefault CodeBuilder
d2l()
Generate an instruction to convert a double into a longdefault CodeBuilder
dadd()
Generate an instruction to add a doubledefault CodeBuilder
daload()
Generate an instruction to load a double from an arraydefault CodeBuilder
dastore()
Generate an instruction to store into a double arraydefault CodeBuilder
dcmpg()
Generate an instruction to add a doubledefault CodeBuilder
dcmpl()
Generate an instruction to compare doublesdefault CodeBuilder
dconst_0()
Generate an instruction pushing double constant 0 onto the operand stackdefault CodeBuilder
dconst_1()
Generate an instruction pushing double constant 1 onto the operand stackdefault CodeBuilder
ddiv()
Generate an instruction to divide doublesdefault CodeBuilder
dload
(int slot) Generate an instruction to load a double from a local variabledefault CodeBuilder
dmul()
Generate an instruction to multiply doublesdefault CodeBuilder
dneg()
Generate an instruction to negate a doubledefault CodeBuilder
drem()
Generate an instruction to calculate double remainderdefault CodeBuilder
dreturn()
Generate an instruction to return a double from the methoddefault CodeBuilder
dstore
(int slot) Generate an instruction to store a double into a local variabledefault CodeBuilder
dsub()
Generate an instruction to subtract doublesdefault CodeBuilder
dup()
Generate an instruction to duplicate the top operand stack valuedefault CodeBuilder
dup_x1()
Generate an instruction to duplicate the top operand stack value and insert two values downdefault CodeBuilder
dup_x2()
Generate an instruction to duplicate the top operand stack value and insert two or three values downdefault CodeBuilder
dup2()
Generate an instruction to duplicate the top one or two operand stack valuedefault CodeBuilder
dup2_x1()
Generate an instruction to duplicate the top one or two operand stack values and insert two or three values downdefault CodeBuilder
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 CodeBuilder
exceptionCatch
(Label start, Label end, Label handler, ClassEntry catchType) Declare an exception table entrydefault CodeBuilder
exceptionCatch
(Label start, Label end, Label handler, ClassDesc catchType) Declare an exception table entrydefault CodeBuilder
exceptionCatch
(Label start, Label end, Label handler, Optional<ClassEntry> catchType) Declare an exception table entrydefault CodeBuilder
exceptionCatchAll
(Label start, Label end, Label handler) Declare an exception table entry catching all exceptions and errorsdefault CodeBuilder
f2d()
Generate an instruction to convert a float into a doubledefault CodeBuilder
f2i()
Generate an instruction to convert a float into an intdefault CodeBuilder
f2l()
Generate an instruction to convert a float into a longdefault CodeBuilder
fadd()
Generate an instruction to add a floatdefault CodeBuilder
faload()
Generate an instruction to load a float from an arraydefault CodeBuilder
fastore()
Generate an instruction to store into a float arraydefault CodeBuilder
fcmpg()
Generate an instruction to compare floatsdefault CodeBuilder
fcmpl()
Generate an instruction to compare floatsdefault CodeBuilder
fconst_0()
Generate an instruction pushing float constant 0 onto the operand stackdefault CodeBuilder
fconst_1()
Generate an instruction pushing float constant 1 onto the operand stackdefault CodeBuilder
fconst_2()
Generate an instruction pushing float constant 2 onto the operand stackdefault CodeBuilder
fdiv()
Generate an instruction to divide floatsdefault CodeBuilder
fieldAccess
(Opcode opcode, FieldRefEntry ref) Generate an instruction to access a fielddefault CodeBuilder
fieldAccess
(Opcode opcode, ClassDesc owner, String name, ClassDesc type) Generate an instruction to access a fielddefault CodeBuilder
fload
(int slot) Generate an instruction to load a float from a local variabledefault CodeBuilder
fmul()
Generate an instruction to multiply floatsdefault CodeBuilder
fneg()
Generate an instruction to negate a floatdefault CodeBuilder
frem()
Generate an instruction to calculate floats remainderdefault CodeBuilder
freturn()
Generate an instruction to return a float from the methoddefault CodeBuilder
fstore
(int slot) Generate an instruction to store a float into a local variabledefault CodeBuilder
fsub()
Generate an instruction to subtract floatsdefault CodeBuilder
getfield
(FieldRefEntry ref) Generate an instruction to fetch field from an objectdefault CodeBuilder
Generate an instruction to fetch field from an objectdefault CodeBuilder
getstatic
(FieldRefEntry ref) Generate an instruction to get static field from a classdefault CodeBuilder
Generate an instruction to get static field from a classdefault CodeBuilder
Generate an instruction to branch alwaysdefault CodeBuilder
Generate an instruction to branch always with wide indexdefault CodeBuilder
i2b()
Generate an instruction to convert an int into a bytedefault CodeBuilder
i2c()
Generate an instruction to convert an int into a chardefault CodeBuilder
i2d()
Generate an instruction to convert an int into a doubledefault CodeBuilder
i2f()
Generate an instruction to convert an int into a floatdefault CodeBuilder
i2l()
Generate an instruction to convert an int into a longdefault CodeBuilder
i2s()
Generate an instruction to convert an int into a shortdefault CodeBuilder
iadd()
Generate an instruction to add an intdefault CodeBuilder
iaload()
Generate an instruction to load a int from an arraydefault CodeBuilder
iand()
Generate an instruction to calculate boolean AND of intsdefault CodeBuilder
iastore()
Generate an instruction to store into an int arraydefault CodeBuilder
iconst_0()
Generate an instruction pushing int constant 0 onto the operand stackdefault CodeBuilder
iconst_1()
Generate an instruction pushing int constant 1 onto the operand stackdefault CodeBuilder
iconst_2()
Generate an instruction pushing int constant 2 onto the operand stackdefault CodeBuilder
iconst_3()
Generate an instruction pushing int constant 3 onto the operand stackdefault CodeBuilder
iconst_4()
Generate an instruction pushing int constant 4 onto the operand stackdefault CodeBuilder
iconst_5()
Generate an instruction pushing int constant 5 onto the operand stackdefault CodeBuilder
Generate an instruction pushing int constant -1 onto the operand stackdefault CodeBuilder
idiv()
Generate an instruction to divide intsdefault CodeBuilder
Generate an instruction to branch if reference comparison succeedsdefault CodeBuilder
Generate an instruction to branch if reference comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if int comparison with zero succeedsdefault CodeBuilder
Generate an instruction to branch if reference is not nulldefault CodeBuilder
Generate an instruction to branch if reference is nulldefault CodeBuilder
ifThen
(Opcode opcode, Consumer<CodeBuilder.BlockCodeBuilder> 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.default CodeBuilder
ifThen
(Consumer<CodeBuilder.BlockCodeBuilder> thenHandler) Add an "if-then" block that is conditional on the boolean value on top of the operand stack.default CodeBuilder
ifThenElse
(Opcode opcode, Consumer<CodeBuilder.BlockCodeBuilder> thenHandler, Consumer<CodeBuilder.BlockCodeBuilder> 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 CodeBuilder
ifThenElse
(Consumer<CodeBuilder.BlockCodeBuilder> thenHandler, Consumer<CodeBuilder.BlockCodeBuilder> elseHandler) Add an "if-then-else" block that is conditional on the boolean value on top of the operand stack.default CodeBuilder
iinc
(int slot, int val) Generate an instruction to increment a local variable by a constantdefault CodeBuilder
iload
(int slot) Generate an instruction to load an int from a local variabledefault CodeBuilder
imul()
Generate an instruction to multiply intsdefault CodeBuilder
ineg()
Generate an instruction to negate an intdefault CodeBuilder
instanceOf
(ClassEntry target) Generate an instruction to determine if an object is of the given typedefault CodeBuilder
instanceOf
(ClassDesc target) Generate an instruction to determine if an object is of the given typedefault CodeBuilder
invoke
(Opcode opcode, MemberRefEntry ref) Generate an instruction to invoke a method or constructordefault CodeBuilder
invoke
(Opcode opcode, ClassDesc owner, String name, MethodTypeDesc desc, boolean isInterface) Generate an instruction to invoke a method or constructordefault CodeBuilder
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilder
Generate an instruction to invoke a dynamically-computed call sitedefault CodeBuilder
Generate an instruction to invoke an interface methoddefault CodeBuilder
invokeinterface
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke an interface methoddefault CodeBuilder
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilder
Generate an instruction to invoke an instance method; direct invocation of instance initialization methods and methods of the current class and its supertypesdefault CodeBuilder
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 CodeBuilder
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 CodeBuilder
Generate an instruction to invoke a class (static) methoddefault CodeBuilder
Generate an instruction to invoke a class (static) methoddefault CodeBuilder
invokestatic
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke a class (static) methoddefault CodeBuilder
invokestatic
(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) Generate an instruction to invoke a class (static) methoddefault CodeBuilder
Generate an instruction to invoke an instance method; dispatch based on classdefault CodeBuilder
invokevirtual
(ClassDesc owner, String name, MethodTypeDesc type) Generate an instruction to invoke an instance method; dispatch based on classdefault CodeBuilder
ior()
Generate an instruction to calculate boolean OR of intsdefault CodeBuilder
irem()
Generate an instruction to calculate ints remainderdefault CodeBuilder
ireturn()
Generate an instruction to return an int from the methoddefault CodeBuilder
ishl()
Generate an instruction to shift an int leftdefault CodeBuilder
ishr()
Generate an instruction to shift an int rightdefault CodeBuilder
istore
(int slot) Generate an instruction to store an int into a local variabledefault CodeBuilder
isub()
Generate an instruction to subtract intsdefault CodeBuilder
iushr()
Generate an instruction to logical shift an int rightdefault CodeBuilder
ixor()
Generate an instruction to calculate boolean XOR of intsdefault CodeBuilder
l2d()
Generate an instruction to convert a long into a doubledefault CodeBuilder
l2f()
Generate an instruction to convert a long into a floatdefault CodeBuilder
l2i()
Generate an instruction to convert a long into an intdefault CodeBuilder
labelBinding
(Label label) Bind label with current positiondefault CodeBuilder
ladd()
Generate an instruction to add a longdefault CodeBuilder
laload()
Generate an instruction to load a long from an arraydefault CodeBuilder
land()
Generate an instruction to calculate boolean AND of longsdefault CodeBuilder
lastore()
Generate an instruction to store into a long arraydefault CodeBuilder
lcmp()
Generate an instruction to compare longsdefault CodeBuilder
lconst_0()
Generate an instruction pushing long constant 0 onto the operand stackdefault CodeBuilder
lconst_1()
Generate an instruction pushing long constant 1 onto the operand stackdefault CodeBuilder
ldc
(LoadableConstantEntry entry) Generate an instruction pushing an item from the run-time constant pool onto the operand stackdefault CodeBuilder
ldc
(ConstantDesc value) Generate an instruction pushing an item from the run-time constant pool onto the operand stackdefault CodeBuilder
ldiv()
Generate an instruction to divide longsdefault CodeBuilder
lineNumber
(int line) Declare a source line number of the current builder positiondefault CodeBuilder
lload
(int slot) Generate an instruction to load a long from a local variabledefault CodeBuilder
lmul()
Generate an instruction to multiply longsdefault CodeBuilder
lneg()
Generate an instruction to negate a longdefault CodeBuilder
loadConstant
(double value) Generate an instruction pushing a constant double value onto the operand stack.default CodeBuilder
loadConstant
(float value) Generate an instruction pushing a constant float value onto the operand stack.default CodeBuilder
loadConstant
(int value) Generate an instruction pushing a constant int value onto the operand stack.default CodeBuilder
loadConstant
(long value) Generate an instruction pushing a constant long value onto the operand stack.default CodeBuilder
loadConstant
(ConstantDesc value) Generate an instruction pushing a constant onto the operand stackdefault CodeBuilder
Generate an instruction to load a value from a local variabledefault CodeBuilder
localVariable
(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope) Declare a local variable entrydefault CodeBuilder
localVariable
(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) Declare a local variable entrydefault CodeBuilder
localVariableType
(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope) Declare a local variable type entrydefault CodeBuilder
localVariableType
(int slot, String name, Signature signature, Label startScope, Label endScope) Declare a local variable type entrydefault CodeBuilder
lookupswitch
(Label defaultTarget, List<SwitchCase> cases) Generate an instruction to access a jump table by key match and jumpdefault CodeBuilder
lor()
Generate an instruction to calculate boolean OR of longsdefault CodeBuilder
lrem()
Generate an instruction to calculate longs remainderdefault CodeBuilder
lreturn()
Generate an instruction to return a long from the methoddefault CodeBuilder
lshl()
Generate an instruction to shift a long leftdefault CodeBuilder
lshr()
Generate an instruction to shift a long rightdefault CodeBuilder
lstore
(int slot) Generate an instruction to store a long into a local variabledefault CodeBuilder
lsub()
Generate an instruction to subtract longsdefault CodeBuilder
lushr()
Generate an instruction to logical shift a long leftdefault CodeBuilder
lxor()
Generate an instruction to calculate boolean XOR of longsdefault CodeBuilder
Generate an instruction to enter monitor for an objectdefault CodeBuilder
Generate an instruction to exit monitor for an objectdefault CodeBuilder
multianewarray
(ClassEntry array, int dims) Generate an instruction to create a new multidimensional arraydefault CodeBuilder
multianewarray
(ClassDesc array, int dims) Generate an instruction to create a new multidimensional arraydefault CodeBuilder
new_
(ClassEntry clazz) Generate an instruction to create a new objectdefault CodeBuilder
Generate an instruction to create a new objectdefault CodeBuilder
Generate an instruction to create a new array of a primitive typedefault Label
Create new label bound with current positionnewLabel()
Returns a fresh unbound label.default CodeBuilder
nop()
Generate a do nothing instructionint
parameterSlot
(int paramNo) Returns the local variable slot associated with the specified parameter.default CodeBuilder
pop()
Generate an instruction to pop the top operand stack valuedefault CodeBuilder
pop2()
Generate an instruction to pop the top one or two operand stack valuesdefault CodeBuilder
putfield
(FieldRefEntry ref) Generate an instruction to set field in an objectdefault CodeBuilder
Generate an instruction to set field in an objectdefault CodeBuilder
putstatic
(FieldRefEntry ref) Generate an instruction to set static field in a classdefault CodeBuilder
Generate an instruction to set static field in a classint
Returns the local variable slot associated with the receiver.default CodeBuilder
return_()
Generate an instruction to return void from the methoddefault CodeBuilder
Generate return instructiondefault CodeBuilder
saload()
Generate an instruction to load a short from an arraydefault CodeBuilder
sastore()
Generate an instruction to store into a short arraydefault CodeBuilder
sipush
(int s) Generate an instruction pushing an int in the range of short onto the operand stack.Returns the label associated with the beginning of the current block.default CodeBuilder
storeLocal
(TypeKind tk, int slot) Generate an instruction to store a value to a local variabledefault CodeBuilder
swap()
Generate an instruction to swap the top two operand stack valuesdefault CodeBuilder
tableswitch
(int low, int high, Label defaultTarget, List<SwitchCase> cases) Generate an instruction to access a jump table by index and jumpdefault CodeBuilder
tableswitch
(Label defaultTarget, List<SwitchCase> cases) Generate an instruction to access a jump table by index and jumpdefault CodeBuilder
transforming
(CodeTransform transform, Consumer<CodeBuilder> handler) Apply a transform to the code built by a handler, directing results to this builder.default CodeBuilder
trying
(Consumer<CodeBuilder.BlockCodeBuilder> tryHandler, Consumer<CodeBuilder.CatchBuilder> catchesHandler) Adds a "try-catch" block comprising one try block and zero or more catch blocks.Methods declared in interface java.lang.classfile.ClassFileBuilder
accept, constantPool, transform, with
-
Method Details
-
newLabel
-
startLabel
Label startLabel()Returns the label associated with the beginning of the current block. If the current CodeBuilder 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
Label endLabel()Returns the label associated with the end of the current block. If the current CodeBuilder 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 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
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 CodeBuilder 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()
also corresponds to the end of the block.- Parameters:
handler
- handler that receives a CodeBuilder.BlockCodeBuilder 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()
for the "then" block corresponds to the end of that block.- Parameters:
thenHandler
- handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of theif
- Returns:
- this builder
-
ifThen
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()
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.BlockCodeBuilder 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 CodeBuilder ifThenElse(Consumer<CodeBuilder.BlockCodeBuilder> thenHandler, Consumer<CodeBuilder.BlockCodeBuilder> elseHandler) Add an "if-then-else" block that is conditional on the boolean value on top of the operand stack.The
CodeBuilder.BlockCodeBuilder.breakLabel()
for each block corresponds to the end of the "else" block.- Parameters:
thenHandler
- handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of theif
elseHandler
- handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of theelse
- Returns:
- this builder
-
ifThenElse
default CodeBuilder ifThenElse(Opcode opcode, Consumer<CodeBuilder.BlockCodeBuilder> thenHandler, Consumer<CodeBuilder.BlockCodeBuilder> 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()
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.BlockCodeBuilder to generate the body of theif
elseHandler
- handler that receives a CodeBuilder.BlockCodeBuilder 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 CodeBuilder trying(Consumer<CodeBuilder.BlockCodeBuilder> tryHandler, Consumer<CodeBuilder.CatchBuilder> 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 CodeBuilder to generate the body of the try block.catchesHandler
- a handler that receives a CodeBuilder.CatchBuilder to generate bodies of catch blocks.- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the try block is empty.- See Also:
-
loadLocal
Generate an instruction to load a value from a local variable- Parameters:
tk
- the load typeslot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftk
isvoid
orslot
is out of range
-
storeLocal
Generate an instruction to store a value to a local variable- Parameters:
tk
- the store typeslot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- iftk
isvoid
orslot
is out of range
-
branch
Generate a branch instruction- Parameters:
op
- the branch opcodetarget
- the branch target- Returns:
- this builder
- See Also:
-
return_
Generate return instruction- Parameters:
tk
- the return type- Returns:
- this builder
-
fieldAccess
Generate an instruction to access a field- Parameters:
opcode
- the field access opcoderef
- the field reference- Returns:
- this builder
- See Also:
-
fieldAccess
Generate an instruction to access a field- Parameters:
opcode
- the field access opcodeowner
- the classname
- the field nametype
- the field type- Returns:
- this builder
- See Also:
-
invoke
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:
-
invoke
default CodeBuilder invoke(Opcode 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:
-
arrayLoad
Generate an instruction to load from an array- Parameters:
tk
- the array element type- Returns:
- this builder
-
arrayStore
Generate an instruction to store into an array- Parameters:
tk
- the array element type- Returns:
- this builder
-
conversion
Generate instruction(s) to convertfromType
totoType
- Parameters:
fromType
- the source typetoType
- the target type- Returns:
- this builder
- Throws:
IllegalArgumentException
- for conversions ofvoid
orreference
-
loadConstant
Generate an instruction pushing a constant onto the operand stack- Parameters:
value
- the constant value- Returns:
- this builder
-
loadConstant
Generate an instruction pushing a constant int value onto the operand stack. This is identical toloadConstant(Integer.valueOf(value))
.- Parameters:
value
- the int value- Returns:
- this builder
- Since:
- 24
-
loadConstant
Generate an instruction pushing a constant long value onto the operand stack. This is identical toloadConstant(Long.valueOf(value))
.- Parameters:
value
- the long value- Returns:
- this builder
- Since:
- 24
-
loadConstant
Generate an instruction pushing a constant float value onto the operand stack. This is identical toloadConstant(Float.valueOf(value))
.- Parameters:
value
- the float value- Returns:
- this builder
- Since:
- 24
-
loadConstant
Generate an instruction pushing a constant double value onto the operand stack. This is identical toloadConstant(Double.valueOf(value))
.- Parameters:
value
- the double value- Returns:
- this builder
- Since:
- 24
-
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
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 CodeBuilder exceptionCatch(Label start, Label end, Label handler, Optional<ClassEntry> 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
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
Declare an exception table entry catching all exceptions and errors- Parameters:
start
- the try block startend
- the try block endhandler
- the exception handler start- Returns:
- this builder
-
characterRange
default CodeBuilder characterRange(Label startScope, Label 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 CodeBuilder localVariable(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label 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
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
localVariable
default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, Label startScope, Label 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
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
localVariableType
default CodeBuilder localVariableType(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label 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
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
localVariableType
default CodeBuilder localVariableType(int slot, String name, Signature signature, Label startScope, Label 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
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 variableThis may also generate
aload_<N>
andwide aload
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 variableThis may also generate
astore_<N>
andwide astore
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 an int in the range of byte onto the operand stack.- Parameters:
b
- the int in the range of byte- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifb
is out of range of byte
-
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 variableThis may also generate
dload_<N>
andwide dload
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 variableThis may also generate
dstore_<N>
andwide dstore
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 variableThis may also generate
fload_<N>
andwide fload
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 variableThis may also generate
fstore_<N>
andwide fstore
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 alwaysThis may also generate
goto_w
instructions if theFIX_SHORT_JUMPS
option is set.- API Note:
- The instruction's name is
goto
, which coincides with a reserved keyword of the Java programming language, thus this method is named with an extra_
suffix instead. - 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
-
ifnonnull
Generate an instruction to branch if reference is not null- Parameters:
target
- the branch target- Returns:
- this builder
-
ifnull
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
- Throws:
IllegalArgumentException
- ifslot
orval
is out of range
-
iload
Generate an instruction to load an int from a local variableThis may also generate
iload_<N>
andwide iload
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
imul
-
ineg
-
instanceOf
Generate an instruction to determine if an object is of the given type- API Note:
- The instruction's name is
instanceof
, which coincides with a reserved keyword of the Java programming language, thus this method is named with camel case instead. - Parameters:
target
- the target type- Returns:
- this builder
-
instanceOf
Generate an instruction to determine if an object is of the given type- API Note:
- The instruction's name is
instanceof
, which coincides with a reserved keyword of the Java programming language, thus this method is named with camel case instead. - 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 CodeBuilder 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 CodeBuilder 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
-
ishr
-
istore
Generate an instruction to store an int into a local variableThis may also generate
istore_<N>
andwide istore
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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 stackThis may also generate
ldc_w
andldc2_w
instructions.- API Note:
loadConstant
generates more optimal instructions and should be used for general constants if anldc
instruction is not strictly required.- Parameters:
value
- the constant value- Returns:
- this builder
-
ldc
Generate an instruction pushing an item from the run-time constant pool onto the operand stackThis may also generate
ldc_w
andldc2_w
instructions.- Parameters:
entry
- the constant value- Returns:
- this builder
-
ldiv
-
lload
Generate an instruction to load a long from a local variableThis may also generate
lload_<N>
andwide lload
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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
-
lshr
-
lstore
Generate an instruction to store a long into a local variableThis may also generate
lstore_<N>
andwide lstore
instructions.- Parameters:
slot
- the local variable slot- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifslot
is out of range
-
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
- Throws:
IllegalArgumentException
- ifdims
is out of range
-
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 or ifdims
is out of range
-
new_
Generate an instruction to create a new object- API Note:
- The instruction's name is
new
, which coincides with a reserved keyword of the Java programming language, thus this method is named with an extra_
suffix instead. - Parameters:
clazz
- the new class type- Returns:
- this builder
-
new_
Generate an instruction to create a new object- API Note:
- The instruction's name is
new
, which coincides with a reserved keyword of the Java programming language, thus this method is named with an extra_
suffix instead. - 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
- Throws:
IllegalArgumentException
- when thetypeKind
is not a legal primitive array component type
-
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- API Note:
- The instruction's name is
return
, which coincides with a reserved keyword of the Java programming language, thus this method is named with an extra_
suffix instead. - 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 an int in the range of short onto the operand stack.- Parameters:
s
- the int in the range of short- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifs
is out of range of short
-
swap
Generate an instruction to swap the top two operand stack values- Returns:
- this builder
-
tableswitch
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
-