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

# Interface NewPrimitiveArrayInstruction

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

public sealed interface NewPrimitiveArrayInstruction extends InstructionPREVIEW
`NewPrimitiveArrayInstruction` is a preview API of the Java platform.
Programs can only use `NewPrimitiveArrayInstruction` 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 `newarray` invocation instruction in the `code` array of a `Code` attribute. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static NewPrimitiveArrayInstructionPREVIEW`
  `of(TypeKindPREVIEW typeKind)`
  Returns a new primitive array instruction.
  `TypeKindPREVIEW`
  `typeKind()`
  Returns the component type of the array.

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

  `opcode, sizeInBytes`

- ## Method Details

  - ### typeKind

    TypeKindPREVIEW typeKind()
    Returns the component type of the array.
    Returns:
      the component type of the array

  - ### of

    static NewPrimitiveArrayInstructionPREVIEW of(TypeKindPREVIEW typeKind)
    Returns a new primitive array instruction.
    Parameters:
      `typeKind` - the component type of the array
    Returns:
      a new primitive array instruction
    Throws:
      `IllegalArgumentException` - when the `typeKind` is not a legal primitive array component type