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

# Interface NewObjectInstruction

All Superinterfaces:
  `ClassFileElement, CodeElement, Instruction`

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

A new object instruction is composite:

    NewObjectInstruction(ClassEntry className)

where the `className` is a non-abstract class.

See Java Virtual Machine Specification:
  6.5.new new
Since:
  24
See Also:
  - `Opcode.Kind.NEW_OBJECT`
  - `CodeBuilder::new_`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassEntry`
  `className()`
  Returns the type of object to create.
  `static NewObjectInstruction`
  `of(ClassEntry className)`
  Returns a new object instruction.

  ### Methods declared in interface Instruction

  `opcode, sizeInBytes`
  Modifier and Type
  Method
  Description
  `Opcode`
  `opcode()`
  Returns the operation of this instruction.
  `int`
  `sizeInBytes()`
  Returns the size in bytes of this instruction.

- ## Method Details

  - ### className

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

  - ### of

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