Package Summary Overview Summary

Module java.base
Package java.lang.classfile.instructionPREVIEW

# Interface FieldInstruction

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

public sealed interface FieldInstruction extends InstructionPREVIEW
`FieldInstruction` is a preview API of the Java platform.
Programs can only use `FieldInstruction` 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 field access instruction in the `code` array of a `Code` attribute. Corresponding opcodes will have a `kind` of `Opcode.Kind.FIELD_ACCESS`PREVIEW. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FieldRefEntryPREVIEW`
  `field()`
  Returns the `FieldRefEntry`PREVIEW constant described by this instruction.
  `default Utf8EntryPREVIEW`
  `name()`
  Returns the name of the field.
  `static FieldInstructionPREVIEW`
  `of (OpcodePREVIEW op, ClassEntryPREVIEW owner, NameAndTypeEntryPREVIEW nameAndType)`
  Returns a field access instruction.
  `static FieldInstructionPREVIEW`
  `of (OpcodePREVIEW op, ClassEntryPREVIEW owner, Utf8EntryPREVIEW name, Utf8EntryPREVIEW type)`
  Returns a field access instruction.
  `static FieldInstructionPREVIEW`
  `of (OpcodePREVIEW op, FieldRefEntryPREVIEW field)`
  Returns a field access instruction.
  `default ClassEntryPREVIEW`
  `owner()`
  Returns the class holding the field.
  `default Utf8EntryPREVIEW`
  `type()`
  Returns the field descriptor of the field.
  `default ClassDesc`
  `typeSymbol()`
  Returns a symbolic descriptor for the type of the field.

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

  `opcode, sizeInBytes`

- ## Method Details

  - ### field

    FieldRefEntryPREVIEW field()
    Returns the `FieldRefEntry`PREVIEW constant described by this instruction.
    Returns:
      the `FieldRefEntry`PREVIEW constant described by this instruction

  - ### owner

    default ClassEntryPREVIEW owner()
    Returns the class holding the field.
    Returns:
      the class holding the field

  - ### name

    default Utf8EntryPREVIEW name()
    Returns the name of the field.
    Returns:
      the name of the field

  - ### type

    default Utf8EntryPREVIEW type()
    Returns the field descriptor of the field.
    Returns:
      the field descriptor of the field

  - ### typeSymbol

    default ClassDesc typeSymbol()
    Returns a symbolic descriptor for the type of the field.
    Returns:
      a symbolic descriptor for the type of the field

  - ### of

    static FieldInstructionPREVIEW of (OpcodePREVIEW op, FieldRefEntryPREVIEW field)
    Returns a field access instruction.
    Parameters:
      `op` - the opcode for the specific type of field access instruction, which must be of kind `Opcode.Kind.FIELD_ACCESS`PREVIEW
      `field` - a constant pool entry describing the field
    Returns:
      a field access instruction

  - ### of

    static FieldInstructionPREVIEW of (OpcodePREVIEW op, ClassEntryPREVIEW owner, Utf8EntryPREVIEW name, Utf8EntryPREVIEW type)
    Returns a field access instruction.
    Parameters:
      `op` - the opcode for the specific type of field access instruction, which must be of kind `Opcode.Kind.FIELD_ACCESS`PREVIEW
      `owner` - the class holding the field
      `name` - the name of the field
      `type` - the field descriptor
    Returns:
      a field access instruction

  - ### of

    static FieldInstructionPREVIEW of (OpcodePREVIEW op, ClassEntryPREVIEW owner, NameAndTypeEntryPREVIEW nameAndType)
    Returns a field access instruction.
    Parameters:
      `op` - the opcode for the specific type of field access instruction, which must be of kind `Opcode.Kind.FIELD_ACCESS`PREVIEW
      `owner` - the class holding the field
      `nameAndType` - the name and field descriptor of the field
    Returns:
      a field access instruction