Interface CodeBuilder

All Superinterfaces:
ClassFileBuilderPREVIEW<CodeElementPREVIEW,CodeBuilderPREVIEW>, Consumer<CodeElementPREVIEW>
All Known Subinterfaces:
CodeBuilder.BlockCodeBuilderPREVIEW

public sealed interface CodeBuilder extends ClassFileBuilderPREVIEW<CodeElementPREVIEW,CodeBuilderPREVIEW> permits CodeBuilder.BlockCodeBuilderPREVIEW (not exhaustive)
CodeBuilder is a preview API of the Java platform.
Programs can only use CodeBuilder when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A builder for code attributes (method bodies). Builders are not created directly; they are passed to handlers by methods such as MethodBuilder.withCode(Consumer)PREVIEW or to code transforms. The elements of a code can be specified abstractly, by passing a CodeElementPREVIEW to ClassFileBuilder.with(ClassFileElement)PREVIEW 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 like aload. Note that some constant instructions, such as iconst_1, do not have generic versions, and thus have their own factories.
  • Instructions that accept wide operands, such as ldc2_w or wide, share their factories with their regular version like ldc(java.lang.constant.ConstantDesc). Note that goto_w has its own factory to avoid short jumps.
  • The goto, instanceof, new, and return instructions' factories are named goto_, instanceOf, new_, and return_ respectively, due to clashes with keywords in the Java programming language.
  • Factories are not provided for instructions jsr, jsr_w, ret, and wide ret, which cannot appear in class files with major version 51 or higher. (JVMS 4.9.1)
Since:
22
See Also:
  • Method Details

    • newLabel

      LabelPREVIEW newLabel()
      Returns a fresh unbound label.
      Returns:
      a fresh unbound label
    • startLabel

      LabelPREVIEW 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 by block(Consumer) or ifThenElse(Consumer, Consumer), the current block will be the entire method body.
      Returns:
      the label associated with the beginning of the current block
    • endLabel

      LabelPREVIEW 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 by block(Consumer) or ifThenElse(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 that long and double values require two slots.
      Parameters:
      paramNo - the index of the parameter
      Returns:
      the local variable slot associated with the specified parameter
    • allocateLocal

      int allocateLocal(TypeKindPREVIEW typeKind)
      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 the maxLocals 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), or ifThenElse(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 handler
      handler - 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() and endLabel() correspond to the start and end of the block, and the CodeBuilder.BlockCodeBuilder.breakLabel()PREVIEW 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()PREVIEW for the "then" block corresponds to the end of that block.

      Parameters:
      thenHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the if
      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()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 stack
      thenHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the if
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the operation code is not for a branch instruction that accepts one or two operands
    • ifThenElse

      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.BlockCodeBuilder to generate the body of the if
      elseHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the else
      Returns:
      this builder
    • ifThenElse

      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 stack
      thenHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the if
      elseHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the else
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the operation code is not for a branch instruction that accepts one or two operands
    • trying

      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

      default CodeBuilderPREVIEW loadLocal(TypeKindPREVIEW tk, int slot)
      Generate an instruction to load a value from a local variable
      Parameters:
      tk - the load type
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if tk is voidPREVIEW or slot is out of range
      Since:
      23
    • storeLocal

      default CodeBuilderPREVIEW storeLocal(TypeKindPREVIEW tk, int slot)
      Generate an instruction to store a value to a local variable
      Parameters:
      tk - the store type
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if tk is voidPREVIEW or slot is out of range
      Since:
      23
    • branch

      default CodeBuilderPREVIEW branch(OpcodePREVIEW op, LabelPREVIEW target)
      Generate a branch instruction
      Parameters:
      op - the branch opcode
      target - the branch target
      Returns:
      this builder
      Since:
      23
      See Also:
    • return_

      default CodeBuilderPREVIEW return_(TypeKindPREVIEW tk)
      Generate return instruction
      Parameters:
      tk - the return type
      Returns:
      this builder
      Since:
      23
    • fieldAccess

      default CodeBuilderPREVIEW fieldAccess(OpcodePREVIEW opcode, FieldRefEntryPREVIEW ref)
      Generate an instruction to access a field
      Parameters:
      opcode - the field access opcode
      ref - the field reference
      Returns:
      this builder
      Since:
      23
      See Also:
    • fieldAccess

      default CodeBuilderPREVIEW fieldAccess(OpcodePREVIEW opcode, ClassDesc owner, String name, ClassDesc type)
      Generate an instruction to access a field
      Parameters:
      opcode - the field access opcode
      owner - the class
      name - the field name
      type - the field type
      Returns:
      this builder
      Since:
      23
      See Also:
    • invoke

      Generate an instruction to invoke a method or constructor
      Parameters:
      opcode - the invoke opcode
      ref - the interface method or method reference
      Returns:
      this builder
      Since:
      23
      See Also:
    • invoke

      default CodeBuilderPREVIEW invoke(OpcodePREVIEW opcode, ClassDesc owner, String name, MethodTypeDesc desc, boolean isInterface)
      Generate an instruction to invoke a method or constructor
      Parameters:
      opcode - the invoke opcode
      owner - the class
      name - the method name
      desc - the method type
      isInterface - the interface method invocation indication
      Returns:
      this builder
      Since:
      23
      See Also:
    • arrayLoad

      default CodeBuilderPREVIEW arrayLoad(TypeKindPREVIEW tk)
      Generate an instruction to load from an array
      Parameters:
      tk - the array element type
      Returns:
      this builder
      Since:
      23
    • arrayStore

      default CodeBuilderPREVIEW arrayStore(TypeKindPREVIEW tk)
      Generate an instruction to store into an array
      Parameters:
      tk - the array element type
      Returns:
      this builder
      Since:
      23
    • conversion

      default CodeBuilderPREVIEW conversion(TypeKindPREVIEW fromType, TypeKindPREVIEW toType)
      Generate instruction(s) to convert fromType to toType
      Parameters:
      fromType - the source type
      toType - the target type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for conversions of voidPREVIEW or referencePREVIEW
      Since:
      23
    • loadConstant

      default CodeBuilderPREVIEW loadConstant(ConstantDesc value)
      Generate an instruction pushing a constant onto the operand stack
      Parameters:
      value - the constant value
      Returns:
      this builder
      Since:
      23
    • loadConstant

      default CodeBuilderPREVIEW loadConstant(int value)
      Generate an instruction pushing a constant int value onto the operand stack. This is identical to loadConstant(Integer.valueOf(value)).
      Parameters:
      value - the int value
      Returns:
      this builder
      Since:
      24
    • loadConstant

      default CodeBuilderPREVIEW loadConstant(long value)
      Generate an instruction pushing a constant long value onto the operand stack. This is identical to loadConstant(Long.valueOf(value)).
      Parameters:
      value - the long value
      Returns:
      this builder
      Since:
      24
    • loadConstant

      default CodeBuilderPREVIEW loadConstant(float value)
      Generate an instruction pushing a constant float value onto the operand stack. This is identical to loadConstant(Float.valueOf(value)).
      Parameters:
      value - the float value
      Returns:
      this builder
      Since:
      24
    • loadConstant

      default CodeBuilderPREVIEW loadConstant(double value)
      Generate an instruction pushing a constant double value onto the operand stack. This is identical to loadConstant(Double.valueOf(value)).
      Parameters:
      value - the double value
      Returns:
      this builder
      Since:
      24
    • nop

      default CodeBuilderPREVIEW nop()
      Generate a do nothing instruction
      Returns:
      this builder
    • newBoundLabel

      default LabelPREVIEW newBoundLabel()
      Create new label bound with current position
      Returns:
      this builder
    • labelBinding

      default CodeBuilderPREVIEW labelBinding(LabelPREVIEW label)
      Bind label with current position
      Parameters:
      label - the label
      Returns:
      this builder
    • lineNumber

      default CodeBuilderPREVIEW lineNumber(int line)
      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 start
      end - the try block end
      handler - the exception handler start
      catchType - 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 start
      end - the try block end
      handler - the exception handler start
      catchType - 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 start
      end - the try block end
      handler - the exception handler start
      catchType - the catch type
      Returns:
      this builder
    • exceptionCatchAll

      default CodeBuilderPREVIEW exceptionCatchAll(LabelPREVIEW start, LabelPREVIEW end, LabelPREVIEW handler)
      Declare an exception table entry catching all exceptions and errors
      Parameters:
      start - the try block start
      end - the try block end
      handler - the exception handler start
      Returns:
      this builder
    • 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 range
      endScope - the end scope of the character range
      characterRangeStart - 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 slot
      nameEntry - the variable name
      descriptorEntry - the variable descriptor
      startScope - the start scope of the variable
      endScope - the end scope of the variable
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • localVariable

      default CodeBuilderPREVIEW localVariable(int slot, String name, ClassDesc descriptor, LabelPREVIEW startScope, LabelPREVIEW endScope)
      Declare a local variable entry
      Parameters:
      slot - the local variable slot
      name - the variable name
      descriptor - the variable descriptor
      startScope - the start scope of the variable
      endScope - the end scope of the variable
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • 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 slot
      nameEntry - the variable name
      signatureEntry - the variable signature
      startScope - the start scope of the variable
      endScope - the end scope of the variable
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • 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 slot
      name - the variable name
      signature - the variable signature
      startScope - the start scope of the variable
      endScope - the end scope of the variable
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • aconst_null

      default CodeBuilderPREVIEW aconst_null()
      Generate an instruction pushing the null object reference onto the operand stack
      Returns:
      this builder
    • aaload

      default CodeBuilderPREVIEW aaload()
      Generate an instruction to load a reference from an array
      Returns:
      this builder
    • aastore

      default CodeBuilderPREVIEW aastore()
      Generate an instruction to store into a reference array
      Returns:
      this builder
    • aload

      default CodeBuilderPREVIEW aload(int slot)
      Generate an instruction to load a reference from a local variable

      This may also generate aload_<N> and wide aload instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • anewarray

      default CodeBuilderPREVIEW anewarray(ClassEntryPREVIEW classEntry)
      Generate an instruction to create a new array of reference
      Parameters:
      classEntry - the component type
      Returns:
      this builder
    • anewarray

      default CodeBuilderPREVIEW anewarray(ClassDesc className)
      Generate an instruction to create a new array of reference
      Parameters:
      className - the component type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if className represents a primitive type
    • areturn

      default CodeBuilderPREVIEW areturn()
      Generate an instruction to return a reference from the method
      Returns:
      this builder
    • arraylength

      default CodeBuilderPREVIEW arraylength()
      Generate an instruction to get length of an array
      Returns:
      this builder
    • astore

      default CodeBuilderPREVIEW astore(int slot)
      Generate an instruction to store a reference into a local variable

      This may also generate astore_<N> and wide astore instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • athrow

      default CodeBuilderPREVIEW athrow()
      Generate an instruction to throw an exception or error
      Returns:
      this builder
    • baload

      default CodeBuilderPREVIEW baload()
      Generate an instruction to load a byte from a array
      Returns:
      this builder
    • bastore

      default CodeBuilderPREVIEW bastore()
      Generate an instruction to store into a byte array
      Returns:
      this builder
    • bipush

      default CodeBuilderPREVIEW bipush(int b)
      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 - if b is out of range of byte
    • caload

      default CodeBuilderPREVIEW caload()
      Generate an instruction to load a char from an array
      Returns:
      this builder
    • castore

      default CodeBuilderPREVIEW castore()
      Generate an instruction to store into a char array
      Returns:
      this builder
    • checkcast

      default CodeBuilderPREVIEW checkcast(ClassEntryPREVIEW type)
      Generate an instruction to check whether an object is of the given type
      Parameters:
      type - the object type
      Returns:
      this builder
    • checkcast

      default CodeBuilderPREVIEW checkcast(ClassDesc type)
      Generate an instruction to check whether an object is of the given type
      Parameters:
      type - the object type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if type represents a primitive type
    • d2f

      default CodeBuilderPREVIEW d2f()
      Generate an instruction to convert a double into a float
      Returns:
      this builder
    • d2i

      default CodeBuilderPREVIEW d2i()
      Generate an instruction to convert a double into an int
      Returns:
      this builder
    • d2l

      default CodeBuilderPREVIEW d2l()
      Generate an instruction to convert a double into a long
      Returns:
      this builder
    • dadd

      default CodeBuilderPREVIEW dadd()
      Generate an instruction to add a double
      Returns:
      this builder
    • daload

      default CodeBuilderPREVIEW daload()
      Generate an instruction to load a double from an array
      Returns:
      this builder
    • dastore

      default CodeBuilderPREVIEW dastore()
      Generate an instruction to store into a double array
      Returns:
      this builder
    • dcmpg

      default CodeBuilderPREVIEW dcmpg()
      Generate an instruction to add a double
      Returns:
      this builder
    • dcmpl

      default CodeBuilderPREVIEW dcmpl()
      Generate an instruction to compare doubles
      Returns:
      this builder
    • dconst_0

      default CodeBuilderPREVIEW dconst_0()
      Generate an instruction pushing double constant 0 onto the operand stack
      Returns:
      this builder
    • dconst_1

      default CodeBuilderPREVIEW dconst_1()
      Generate an instruction pushing double constant 1 onto the operand stack
      Returns:
      this builder
    • ddiv

      default CodeBuilderPREVIEW ddiv()
      Generate an instruction to divide doubles
      Returns:
      this builder
    • dload

      default CodeBuilderPREVIEW dload(int slot)
      Generate an instruction to load a double from a local variable

      This may also generate dload_<N> and wide dload instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • dmul

      default CodeBuilderPREVIEW dmul()
      Generate an instruction to multiply doubles
      Returns:
      this builder
    • dneg

      default CodeBuilderPREVIEW dneg()
      Generate an instruction to negate a double
      Returns:
      this builder
    • drem

      default CodeBuilderPREVIEW drem()
      Generate an instruction to calculate double remainder
      Returns:
      this builder
    • dreturn

      default CodeBuilderPREVIEW dreturn()
      Generate an instruction to return a double from the method
      Returns:
      this builder
    • dstore

      default CodeBuilderPREVIEW dstore(int slot)
      Generate an instruction to store a double into a local variable

      This may also generate dstore_<N> and wide dstore instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • dsub

      default CodeBuilderPREVIEW dsub()
      Generate an instruction to subtract doubles
      Returns:
      this builder
    • dup

      default CodeBuilderPREVIEW dup()
      Generate an instruction to duplicate the top operand stack value
      Returns:
      this builder
    • dup2

      default CodeBuilderPREVIEW dup2()
      Generate an instruction to duplicate the top one or two operand stack value
      Returns:
      this builder
    • dup2_x1

      default CodeBuilderPREVIEW 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

      default CodeBuilderPREVIEW 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

      default CodeBuilderPREVIEW dup_x1()
      Generate an instruction to duplicate the top operand stack value and insert two values down
      Returns:
      this builder
    • dup_x2

      default CodeBuilderPREVIEW dup_x2()
      Generate an instruction to duplicate the top operand stack value and insert two or three values down
      Returns:
      this builder
    • f2d

      default CodeBuilderPREVIEW f2d()
      Generate an instruction to convert a float into a double
      Returns:
      this builder
    • f2i

      default CodeBuilderPREVIEW f2i()
      Generate an instruction to convert a float into an int
      Returns:
      this builder
    • f2l

      default CodeBuilderPREVIEW f2l()
      Generate an instruction to convert a float into a long
      Returns:
      this builder
    • fadd

      default CodeBuilderPREVIEW fadd()
      Generate an instruction to add a float
      Returns:
      this builder
    • faload

      default CodeBuilderPREVIEW faload()
      Generate an instruction to load a float from an array
      Returns:
      this builder
    • fastore

      default CodeBuilderPREVIEW fastore()
      Generate an instruction to store into a float array
      Returns:
      this builder
    • fcmpg

      default CodeBuilderPREVIEW fcmpg()
      Generate an instruction to compare floats
      Returns:
      this builder
    • fcmpl

      default CodeBuilderPREVIEW fcmpl()
      Generate an instruction to compare floats
      Returns:
      this builder
    • fconst_0

      default CodeBuilderPREVIEW fconst_0()
      Generate an instruction pushing float constant 0 onto the operand stack
      Returns:
      this builder
    • fconst_1

      default CodeBuilderPREVIEW fconst_1()
      Generate an instruction pushing float constant 1 onto the operand stack
      Returns:
      this builder
    • fconst_2

      default CodeBuilderPREVIEW fconst_2()
      Generate an instruction pushing float constant 2 onto the operand stack
      Returns:
      this builder
    • fdiv

      default CodeBuilderPREVIEW fdiv()
      Generate an instruction to divide floats
      Returns:
      this builder
    • fload

      default CodeBuilderPREVIEW fload(int slot)
      Generate an instruction to load a float from a local variable

      This may also generate fload_<N> and wide fload instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • fmul

      default CodeBuilderPREVIEW fmul()
      Generate an instruction to multiply floats
      Returns:
      this builder
    • fneg

      default CodeBuilderPREVIEW fneg()
      Generate an instruction to negate a float
      Returns:
      this builder
    • frem

      default CodeBuilderPREVIEW frem()
      Generate an instruction to calculate floats remainder
      Returns:
      this builder
    • freturn

      default CodeBuilderPREVIEW freturn()
      Generate an instruction to return a float from the method
      Returns:
      this builder
    • fstore

      default CodeBuilderPREVIEW fstore(int slot)
      Generate an instruction to store a float into a local variable

      This may also generate fstore_<N> and wide fstore instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • fsub

      default CodeBuilderPREVIEW fsub()
      Generate an instruction to subtract floats
      Returns:
      this builder
    • getfield

      default CodeBuilderPREVIEW getfield(FieldRefEntryPREVIEW ref)
      Generate an instruction to fetch field from an object
      Parameters:
      ref - the field reference
      Returns:
      this builder
    • getfield

      default CodeBuilderPREVIEW getfield(ClassDesc owner, String name, ClassDesc type)
      Generate an instruction to fetch field from an object
      Parameters:
      owner - the owner class
      name - the field name
      type - the field type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • getstatic

      default CodeBuilderPREVIEW getstatic(FieldRefEntryPREVIEW ref)
      Generate an instruction to get static field from a class
      Parameters:
      ref - the field reference
      Returns:
      this builder
    • getstatic

      default CodeBuilderPREVIEW getstatic(ClassDesc owner, String name, ClassDesc type)
      Generate an instruction to get static field from a class
      Parameters:
      owner - the owner class
      name - the field name
      type - the field type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • goto_

      default CodeBuilderPREVIEW goto_(LabelPREVIEW target)
      Generate an instruction to branch always

      This may also generate goto_w instructions if the FIX_SHORT_JUMPSPREVIEW 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

      default CodeBuilderPREVIEW goto_w(LabelPREVIEW target)
      Generate an instruction to branch always with wide index
      Parameters:
      target - the branch target
      Returns:
      this builder
    • i2b

      default CodeBuilderPREVIEW i2b()
      Generate an instruction to convert an int into a byte
      Returns:
      this builder
    • i2c

      default CodeBuilderPREVIEW i2c()
      Generate an instruction to convert an int into a char
      Returns:
      this builder
    • i2d

      default CodeBuilderPREVIEW i2d()
      Generate an instruction to convert an int into a double
      Returns:
      this builder
    • i2f

      default CodeBuilderPREVIEW i2f()
      Generate an instruction to convert an int into a float
      Returns:
      this builder
    • i2l

      default CodeBuilderPREVIEW i2l()
      Generate an instruction to convert an int into a long
      Returns:
      this builder
    • i2s

      default CodeBuilderPREVIEW i2s()
      Generate an instruction to convert an int into a short
      Returns:
      this builder
    • iadd

      default CodeBuilderPREVIEW iadd()
      Generate an instruction to add an int
      Returns:
      this builder
    • iaload

      default CodeBuilderPREVIEW iaload()
      Generate an instruction to load a int from an array
      Returns:
      this builder
    • iand

      default CodeBuilderPREVIEW iand()
      Generate an instruction to calculate boolean AND of ints
      Returns:
      this builder
    • iastore

      default CodeBuilderPREVIEW iastore()
      Generate an instruction to store into an int array
      Returns:
      this builder
    • iconst_0

      default CodeBuilderPREVIEW iconst_0()
      Generate an instruction pushing int constant 0 onto the operand stack
      Returns:
      this builder
    • iconst_1

      default CodeBuilderPREVIEW iconst_1()
      Generate an instruction pushing int constant 1 onto the operand stack
      Returns:
      this builder
    • iconst_2

      default CodeBuilderPREVIEW iconst_2()
      Generate an instruction pushing int constant 2 onto the operand stack
      Returns:
      this builder
    • iconst_3

      default CodeBuilderPREVIEW iconst_3()
      Generate an instruction pushing int constant 3 onto the operand stack
      Returns:
      this builder
    • iconst_4

      default CodeBuilderPREVIEW iconst_4()
      Generate an instruction pushing int constant 4 onto the operand stack
      Returns:
      this builder
    • iconst_5

      default CodeBuilderPREVIEW iconst_5()
      Generate an instruction pushing int constant 5 onto the operand stack
      Returns:
      this builder
    • iconst_m1

      default CodeBuilderPREVIEW iconst_m1()
      Generate an instruction pushing int constant -1 onto the operand stack
      Returns:
      this builder
    • idiv

      default CodeBuilderPREVIEW idiv()
      Generate an instruction to divide ints
      Returns:
      this builder
    • if_acmpeq

      default CodeBuilderPREVIEW if_acmpeq(LabelPREVIEW target)
      Generate an instruction to branch if reference comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_acmpne

      default CodeBuilderPREVIEW if_acmpne(LabelPREVIEW target)
      Generate an instruction to branch if reference comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmpeq

      default CodeBuilderPREVIEW if_icmpeq(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmpge

      default CodeBuilderPREVIEW if_icmpge(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmpgt

      default CodeBuilderPREVIEW if_icmpgt(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmple

      default CodeBuilderPREVIEW if_icmple(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmplt

      default CodeBuilderPREVIEW if_icmplt(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • if_icmpne

      default CodeBuilderPREVIEW if_icmpne(LabelPREVIEW target)
      Generate an instruction to branch if int comparison succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifnonnull

      default CodeBuilderPREVIEW ifnonnull(LabelPREVIEW target)
      Generate an instruction to branch if reference is not null
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifnull

      default CodeBuilderPREVIEW ifnull(LabelPREVIEW target)
      Generate an instruction to branch if reference is null
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifeq

      default CodeBuilderPREVIEW ifeq(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifge

      default CodeBuilderPREVIEW ifge(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifgt

      default CodeBuilderPREVIEW ifgt(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifle

      default CodeBuilderPREVIEW ifle(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • iflt

      default CodeBuilderPREVIEW iflt(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • ifne

      default CodeBuilderPREVIEW ifne(LabelPREVIEW target)
      Generate an instruction to branch if int comparison with zero succeeds
      Parameters:
      target - the branch target
      Returns:
      this builder
    • iinc

      default CodeBuilderPREVIEW iinc(int slot, int val)
      Generate an instruction to increment a local variable by a constant
      Parameters:
      slot - the local variable slot
      val - the increment value
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot or val is out of range
    • iload

      default CodeBuilderPREVIEW iload(int slot)
      Generate an instruction to load an int from a local variable

      This may also generate iload_<N> and wide iload instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • imul

      default CodeBuilderPREVIEW imul()
      Generate an instruction to multiply ints
      Returns:
      this builder
    • ineg

      default CodeBuilderPREVIEW ineg()
      Generate an instruction to negate an int
      Returns:
      this builder
    • instanceOf

      default CodeBuilderPREVIEW instanceOf(ClassEntryPREVIEW target)
      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
      Since:
      23
    • instanceOf

      default CodeBuilderPREVIEW instanceOf(ClassDesc target)
      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 - if target represents a primitive type
      Since:
      23
    • invokedynamic

      default CodeBuilderPREVIEW invokedynamic(InvokeDynamicEntryPREVIEW ref)
      Generate an instruction to invoke a dynamically-computed call site
      Parameters:
      ref - the dynamic call site
      Returns:
      this builder
    • invokedynamic

      default CodeBuilderPREVIEW invokedynamic(DynamicCallSiteDesc ref)
      Generate an instruction to invoke a dynamically-computed call site
      Parameters:
      ref - the dynamic call site
      Returns:
      this builder
    • invokeinterface

      default CodeBuilderPREVIEW invokeinterface(InterfaceMethodRefEntryPREVIEW ref)
      Generate an instruction to invoke an interface method
      Parameters:
      ref - the interface method reference
      Returns:
      this builder
    • invokeinterface

      default CodeBuilderPREVIEW invokeinterface(ClassDesc owner, String name, MethodTypeDesc type)
      Generate an instruction to invoke an interface method
      Parameters:
      owner - the owner class
      name - the method name
      type - the method type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner 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

      default CodeBuilderPREVIEW invokespecial(MethodRefEntryPREVIEW ref)
      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

      default 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 supertypes
      Parameters:
      owner - the owner class
      name - the method name
      type - the method type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner 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 class
      name - the method name
      type - the method type
      isInterface - the interface method invocation indication
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • invokestatic

      Generate an instruction to invoke a class (static) method
      Parameters:
      ref - the interface method reference
      Returns:
      this builder
    • invokestatic

      default CodeBuilderPREVIEW invokestatic(MethodRefEntryPREVIEW ref)
      Generate an instruction to invoke a class (static) method
      Parameters:
      ref - the method reference
      Returns:
      this builder
    • invokestatic

      default CodeBuilderPREVIEW invokestatic(ClassDesc owner, String name, MethodTypeDesc type)
      Generate an instruction to invoke a class (static) method
      Parameters:
      owner - the owner class
      name - the method name
      type - the method type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner 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 class
      name - the method name
      type - the method type
      isInterface - the interface method invocation indication
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • invokevirtual

      default CodeBuilderPREVIEW invokevirtual(MethodRefEntryPREVIEW ref)
      Generate an instruction to invoke an instance method; dispatch based on class
      Parameters:
      ref - the method reference
      Returns:
      this builder
    • invokevirtual

      default CodeBuilderPREVIEW invokevirtual(ClassDesc owner, String name, MethodTypeDesc type)
      Generate an instruction to invoke an instance method; dispatch based on class
      Parameters:
      owner - the owner class
      name - the method name
      type - the method type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • ior

      default CodeBuilderPREVIEW ior()
      Generate an instruction to calculate boolean OR of ints
      Returns:
      this builder
    • irem

      default CodeBuilderPREVIEW irem()
      Generate an instruction to calculate ints remainder
      Returns:
      this builder
    • ireturn

      default CodeBuilderPREVIEW ireturn()
      Generate an instruction to return an int from the method
      Returns:
      this builder
    • ishl

      default CodeBuilderPREVIEW ishl()
      Generate an instruction to shift an int left
      Returns:
      this builder
    • ishr

      default CodeBuilderPREVIEW ishr()
      Generate an instruction to shift an int right
      Returns:
      this builder
    • istore

      default CodeBuilderPREVIEW istore(int slot)
      Generate an instruction to store an int into a local variable

      This may also generate istore_<N> and wide istore instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • isub

      default CodeBuilderPREVIEW isub()
      Generate an instruction to subtract ints
      Returns:
      this builder
    • iushr

      default CodeBuilderPREVIEW iushr()
      Generate an instruction to logical shift an int right
      Returns:
      this builder
    • ixor

      default CodeBuilderPREVIEW ixor()
      Generate an instruction to calculate boolean XOR of ints
      Returns:
      this builder
    • lookupswitch

      default CodeBuilderPREVIEW lookupswitch(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases)
      Generate an instruction to access a jump table by key match and jump
      Parameters:
      defaultTarget - the default jump target
      cases - the switch cases
      Returns:
      this builder
    • l2d

      default CodeBuilderPREVIEW l2d()
      Generate an instruction to convert a long into a double
      Returns:
      this builder
    • l2f

      default CodeBuilderPREVIEW l2f()
      Generate an instruction to convert a long into a float
      Returns:
      this builder
    • l2i

      default CodeBuilderPREVIEW l2i()
      Generate an instruction to convert a long into an int
      Returns:
      this builder
    • ladd

      default CodeBuilderPREVIEW ladd()
      Generate an instruction to add a long
      Returns:
      this builder
    • laload

      default CodeBuilderPREVIEW laload()
      Generate an instruction to load a long from an array
      Returns:
      this builder
    • land

      default CodeBuilderPREVIEW land()
      Generate an instruction to calculate boolean AND of longs
      Returns:
      this builder
    • lastore

      default CodeBuilderPREVIEW lastore()
      Generate an instruction to store into a long array
      Returns:
      this builder
    • lcmp

      default CodeBuilderPREVIEW lcmp()
      Generate an instruction to compare longs
      Returns:
      this builder
    • lconst_0

      default CodeBuilderPREVIEW lconst_0()
      Generate an instruction pushing long constant 0 onto the operand stack
      Returns:
      this builder
    • lconst_1

      default CodeBuilderPREVIEW lconst_1()
      Generate an instruction pushing long constant 1 onto the operand stack
      Returns:
      this builder
    • ldc

      default CodeBuilderPREVIEW ldc(ConstantDesc value)
      Generate an instruction pushing an item from the run-time constant pool onto the operand stack

      This may also generate ldc_w and ldc2_w instructions.

      API Note:
      loadConstant generates more optimal instructions and should be used for general constants if an ldc 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 stack

      This may also generate ldc_w and ldc2_w instructions.

      Parameters:
      entry - the constant value
      Returns:
      this builder
    • ldiv

      default CodeBuilderPREVIEW ldiv()
      Generate an instruction to divide longs
      Returns:
      this builder
    • lload

      default CodeBuilderPREVIEW lload(int slot)
      Generate an instruction to load a long from a local variable

      This may also generate lload_<N> and wide lload instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • lmul

      default CodeBuilderPREVIEW lmul()
      Generate an instruction to multiply longs
      Returns:
      this builder
    • lneg

      default CodeBuilderPREVIEW lneg()
      Generate an instruction to negate a long
      Returns:
      this builder
    • lor

      default CodeBuilderPREVIEW lor()
      Generate an instruction to calculate boolean OR of longs
      Returns:
      this builder
    • lrem

      default CodeBuilderPREVIEW lrem()
      Generate an instruction to calculate longs remainder
      Returns:
      this builder
    • lreturn

      default CodeBuilderPREVIEW lreturn()
      Generate an instruction to return a long from the method
      Returns:
      this builder
    • lshl

      default CodeBuilderPREVIEW lshl()
      Generate an instruction to shift a long left
      Returns:
      this builder
    • lshr

      default CodeBuilderPREVIEW lshr()
      Generate an instruction to shift a long right
      Returns:
      this builder
    • lstore

      default CodeBuilderPREVIEW lstore(int slot)
      Generate an instruction to store a long into a local variable

      This may also generate lstore_<N> and wide lstore instructions.

      Parameters:
      slot - the local variable slot
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if slot is out of range
    • lsub

      default CodeBuilderPREVIEW lsub()
      Generate an instruction to subtract longs
      Returns:
      this builder
    • lushr

      default CodeBuilderPREVIEW lushr()
      Generate an instruction to logical shift a long left
      Returns:
      this builder
    • lxor

      default CodeBuilderPREVIEW lxor()
      Generate an instruction to calculate boolean XOR of longs
      Returns:
      this builder
    • monitorenter

      default CodeBuilderPREVIEW monitorenter()
      Generate an instruction to enter monitor for an object
      Returns:
      this builder
    • monitorexit

      default CodeBuilderPREVIEW monitorexit()
      Generate an instruction to exit monitor for an object
      Returns:
      this builder
    • multianewarray

      default CodeBuilderPREVIEW multianewarray(ClassEntryPREVIEW array, int dims)
      Generate an instruction to create a new multidimensional array
      Parameters:
      array - the array type
      dims - the number of dimensions
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if dims is out of range
    • multianewarray

      default CodeBuilderPREVIEW multianewarray(ClassDesc array, int dims)
      Generate an instruction to create a new multidimensional array
      Parameters:
      array - the array type
      dims - the number of dimensions
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if array represents a primitive type or if dims is out of range
    • new_

      default CodeBuilderPREVIEW new_(ClassEntryPREVIEW clazz)
      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_

      default CodeBuilderPREVIEW new_(ClassDesc clazz)
      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 - if clazz represents a primitive type
    • newarray

      default CodeBuilderPREVIEW newarray(TypeKindPREVIEW typeKind)
      Generate an instruction to create a new array of a primitive type
      Parameters:
      typeKind - the primitive array type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - when the typeKind is not a legal primitive array component type
    • pop

      default CodeBuilderPREVIEW pop()
      Generate an instruction to pop the top operand stack value
      Returns:
      this builder
    • pop2

      default CodeBuilderPREVIEW pop2()
      Generate an instruction to pop the top one or two operand stack values
      Returns:
      this builder
    • putfield

      default CodeBuilderPREVIEW putfield(FieldRefEntryPREVIEW ref)
      Generate an instruction to set field in an object
      Parameters:
      ref - the field reference
      Returns:
      this builder
    • putfield

      default CodeBuilderPREVIEW putfield(ClassDesc owner, String name, ClassDesc type)
      Generate an instruction to set field in an object
      Parameters:
      owner - the owner class
      name - the field name
      type - the field type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • putstatic

      default CodeBuilderPREVIEW putstatic(FieldRefEntryPREVIEW ref)
      Generate an instruction to set static field in a class
      Parameters:
      ref - the field reference
      Returns:
      this builder
    • putstatic

      default CodeBuilderPREVIEW putstatic(ClassDesc owner, String name, ClassDesc type)
      Generate an instruction to set static field in a class
      Parameters:
      owner - the owner class
      name - the field name
      type - the field type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if owner represents a primitive type
    • return_

      default CodeBuilderPREVIEW 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

      default CodeBuilderPREVIEW saload()
      Generate an instruction to load a short from an array
      Returns:
      this builder
    • sastore

      default CodeBuilderPREVIEW sastore()
      Generate an instruction to store into a short array
      Returns:
      this builder
    • sipush

      default CodeBuilderPREVIEW sipush(int s)
      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 - if s is out of range of short
    • swap

      default CodeBuilderPREVIEW 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 value
      high - the high key value
      defaultTarget - the default jump target
      cases - the switch cases
      Returns:
      this builder
    • tableswitch

      default CodeBuilderPREVIEW tableswitch(LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases)
      Generate an instruction to access a jump table by index and jump
      Parameters:
      defaultTarget - the default jump target
      cases - the switch cases
      Returns:
      this builder