StoreInstruction (Java SE 22 & JDK 22)
Description: declaration: module: java.base, package: java.lang.classfile.instruction, interface: StoreInstruction
Keywords: java.lang.classfile.instruction.StoreInstruction interface

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

# Interface StoreInstruction

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

public sealed interface StoreInstruction extends InstructionPREVIEW
`StoreInstruction` is a preview API of the Java platform.
Programs can only use `StoreInstruction` 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 store instruction in the `code` array of a `Code` attribute. Corresponding opcodes will have a `kind` of `Opcode.Kind.STORE`PREVIEW. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

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

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

  `opcode, sizeInBytes`

- ## Method Details

  - ### slot

    int slot()
    Returns the local variable slot to store to.
    Returns:
      the local variable slot to store to

  - ### typeKind

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

  - ### of

    static StoreInstructionPREVIEW of(TypeKindPREVIEW kind, int slot)
    Returns a local variable store instruction.
    Parameters:
      `kind` - the type of the value to be stored
      `slot` - the local variable slot to store to
    Returns:
      a local variable store instruction

  - ### of

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