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

# Interface StackInstruction

All Superinterfaces:
  `ClassFileElement, CodeElement, Instruction`

public sealed interface StackInstruction extends Instruction
Models a stack manipulation instruction in the `code` array of a `Code` attribute. Corresponding opcodes have a kind of `Opcode.Kind.STACK`. Delivered as a `CodeElement` when traversing the elements of a `CodeModel`.

A stack manipulation instruction is composite:

    StackInstruction(Opcode opcode)

Since:
  24
See Also:
  - `Opcode.Kind.STACK`

- ## Method Summary

  Static Methods
  Modifier and Type
  Method
  Description
  `static StackInstruction`
  `of(Opcode op)`
  Returns a stack manipulation instruction.

  ### Methods declared in interface Instruction

  `opcode, sizeInBytes`

- ## Method Details

  - ### of

    static StackInstruction of(Opcode op)
    Returns a stack manipulation instruction.
    Parameters:
      `op` - the opcode for the specific type of stack instruction, which must be of kind `Opcode.Kind.STACK`
    Returns:
      a stack manipulation instruction
    Throws:
      `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.STACK`.