# Interface FieldInstruction

All Superinterfaces:
  `ClassFileElement, CodeElement, Instruction`

public sealed interface FieldInstruction extends Instruction
Models a field access instruction in the `code` array of a `Code` attribute. Corresponding opcodes have a kind of `Opcode.Kind.FIELD_ACCESS`. Delivered as a `CodeElement` when traversing the elements of a `CodeModel`.

A field access instruction is composite:

    FieldInstruction(
        Opcode opcode,
        FieldRefEntry field,
    )

Since:
  24
See Also:
  - `Opcode.Kind.FIELD_ACCESS`
  - `CodeBuilder::fieldAccess`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FieldRefEntry`
  `field()`
  Returns the `FieldRefEntry` constant described by this instruction.
  `default Utf8Entry`
  `name()`
  Returns the name of the field.
  `static FieldInstruction`
  `of(Opcode op, ClassEntry owner, NameAndTypeEntry nameAndType)`
  Returns a field access instruction.
  `static FieldInstruction`
  `of(Opcode op, ClassEntry owner, Utf8Entry name, Utf8Entry type)`
  Returns a field access instruction.
  `static FieldInstruction`
  `of(Opcode op, FieldRefEntry field)`
  Returns a field access instruction.
  `default ClassEntry`
  `owner()`
  Returns the class holding the field.
  `default Utf8Entry`
  `type()`
  Returns the field descriptor string of the field.
  `default ClassDesc`
  `typeSymbol()`
  Returns a symbolic descriptor for the type of the field.

  ### 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

  - ### field

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

  - ### owner

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

  - ### name

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

  - ### type

    default Utf8Entry type()
    Returns the field descriptor string of the field.
    API Note:
      A symbolic descriptor for the type of the field is available through `typeSymbol()`.
    Returns:
      the field descriptor string 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 FieldInstruction of(Opcode op, FieldRefEntry 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`
      `field` - a constant pool entry describing the field
    Returns:
      a field access instruction
    Throws:
      `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.FIELD_ACCESS`.

  - ### of

    static FieldInstruction of(Opcode op, ClassEntry owner, Utf8Entry name, Utf8Entry 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`
      `owner` - the class holding the field
      `name` - the name of the field
      `type` - the field descriptor
    Returns:
      a field access instruction
    Throws:
      `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.FIELD_ACCESS`.

  - ### of

    static FieldInstruction of(Opcode op, ClassEntry owner, NameAndTypeEntry 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`
      `owner` - the class holding the field
      `nameAndType` - the name and field descriptor of the field
    Returns:
      a field access instruction
    Throws:
      `IllegalArgumentException` - if the opcode kind is not `Opcode.Kind.FIELD_ACCESS`.