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

# Interface NewReferenceArrayInstruction

All Superinterfaces:
  `ClassFileElement, CodeElement, Instruction`

public sealed interface NewReferenceArrayInstruction extends Instruction
Models a `anewarray` instruction in the `code` array of a `Code` attribute. Delivered as a `CodeElement` when traversing the elements of a `CodeModel`.

A new reference array instruction is composite:

    NewReferenceArrayInstruction(ClassEntry componentType)

See Java Virtual Machine Specification:
  6.5.anewarray anewarray
Since:
  24
See Also:
  - `Opcode.Kind.NEW_REF_ARRAY`
  - CodeBuilder::anewarray

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassEntry`
  `componentType()`
  Returns the component type of the array.
  `static NewReferenceArrayInstruction`
  `of(ClassEntry componentType)`
  Returns a new reference array instruction.

  ### Methods declared in interface Instruction

  `opcode, sizeInBytes`

- ## Method Details

  - ### componentType

    ClassEntry componentType()
    Returns the component type of the array.
    Returns:
      the component type of the array

  - ### of

    static NewReferenceArrayInstruction of(ClassEntry componentType)
    Returns a new reference array instruction.
    Parameters:
      `componentType` - the component type of the array
    Returns:
      a new reference array instruction