Module java.base
Package java.lang.classfile.instructionPREVIEW

# Interface LoadInstruction

All Superinterfaces:
  `ClassFileElementPREVIEW`, `CodeElementPREVIEW`, `InstructionPREVIEW`

public sealed interface LoadInstruction extends InstructionPREVIEW
`LoadInstruction` is a preview API of the Java platform.
Programs can only use `LoadInstruction` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a local variable load instruction in the `code` array of a `Code` attribute. Corresponding opcodes will have a `kind` of `Opcode.Kind.LOAD`PREVIEW. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static LoadInstructionPREVIEW`
  `of(OpcodePREVIEW op, int slot)`
  Returns a local variable load instruction.
  `static LoadInstructionPREVIEW`
  `of(TypeKindPREVIEW kind, int slot)`
  Returns a local variable load instruction.
  `int`
  `slot()`
  Returns the local variable slot to load from.
  `TypeKindPREVIEW`
  `typeKind()`
  Returns the type of the value to be loaded.

  ### Methods declared in interface java.lang.classfile.InstructionPREVIEW

  `opcode, sizeInBytes`

- ## Method Details

  - ### slot

    int slot()
    Returns the local variable slot to load from.
    Returns:
      the local variable slot to load from

  - ### typeKind

    TypeKindPREVIEW typeKind()
    Returns the type of the value to be loaded.
    Returns:
      the type of the value to be loaded

  - ### of

    static LoadInstructionPREVIEW of(TypeKindPREVIEW kind, int slot)
    Returns a local variable load instruction.
    Parameters:
      `kind` - the type of the value to be loaded
      `slot` - the local variable slot to load from
    Returns:
      a local variable load instruction

  - ### of

    static LoadInstructionPREVIEW of(OpcodePREVIEW op, int slot)
    Returns a local variable load instruction.
    Parameters:
      `op` - the opcode for the specific type of load instruction, which must be of kind `Opcode.Kind.LOAD`PREVIEW
      `slot` - the local variable slot to load from
    Returns:
      a local variable load instruction