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

# Interface NewObjectInstruction

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

public sealed interface NewObjectInstruction extends InstructionPREVIEW
`NewObjectInstruction` is a preview API of the Java platform.
Programs can only use `NewObjectInstruction` 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 `new` 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
  `ClassEntryPREVIEW`
  `className()`
  Returns the type of object to create.
  `static NewObjectInstructionPREVIEW`
  `of(ClassEntryPREVIEW className)`
  Returns a new object instruction.

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

  `opcode, sizeInBytes`

- ## Method Details

  - ### className

    ClassEntryPREVIEW className()
    Returns the type of object to create.
    Returns:
      the type of object to create

  - ### of

    static NewObjectInstructionPREVIEW of(ClassEntryPREVIEW className)
    Returns a new object instruction.
    Parameters:
      `className` - the type of object to create
    Returns:
      a new object instruction