Module java.base
Package java.lang.classfile

# Interface FieldModel

≠
public abstract sealed interface FieldModel
extends java.lang.classfile.AttributedElement, java.lang.classfile.ClassElement, java.lang.classfile.CompoundElement<java.lang.classfile.FieldElement>
permits jdk.internal.classfile.impl.FieldImpl, jdk.internal.classfile.impl.BufferedFieldBuilder.Model
Comparing master and cf

All Superinterfaces:
  `AttributedElement, ClassElement, ClassFileElement, CompoundElement<FieldElement>, Iterable<FieldElement>`

public sealed interface FieldModel extends CompoundElement<FieldElement>, AttributedElement, ClassElement
Models a field. The contents of the A field can be traversed via a streaming viewviewed as a composition of `FieldElement` s, or via by random access (e.g., `flags()` ), or by freely mixing the two.

Since:
  24

via accessor methods if only specific parts of the field is needed.

Fields can be obtained from `ClassModel.fields()` , or in the traversal of member elements of a class.

`ClassBuilder.withField(String, ClassDesc, Consumer)` is the main way to construct fields. `ClassBuilder.transformField(FieldModel, FieldTransform)` allows creating a new field by selectively processing the original field elements and directing the results to a field builder.

All field attributes are accessible as member elements.

See Java Virtual Machine Specification:
  4.5 Fields
Since:
  24
See Also:
  - `ClassModel.fields()`
  - `FieldTransform`

## Methods

- =
  public abstract java.lang.classfile.constantpool.Utf8Entry fieldName()
- ≠
  public abstract java.lang.classfile.constantpool.Utf8Entry fieldType()
  Comparing master and cf

  ### fieldType

  Utf8Entry fieldType()
  Returns the field descriptor string of this field.
  Returns:
    the field descriptor string of this field
- ≠
  public default java.lang.constant.ClassDesc fieldTypeSymbol()
  Comparing master and cf

  ### fieldTypeSymbol

  default ClassDesc fieldTypeSymbol()
  Returns the field descriptor of this fieldtype, as a symbolic descriptor.
  Returns:
    the field descriptor of this fieldtype, as a symbolic descriptor
- ≠
  public abstract java.lang.classfile.AccessFlags flags()
  Comparing master and cf

  ### flags

  AccessFlags flags()
  Returns the access flags.
  Returns:
    the access flags
  See Also:
    Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
    - `AccessFlag.Location.FIELD`
- =
  public abstract java.util.Optional<java.lang.classfile.ClassModel> parent()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
FieldModel |  |  |  |  |  |  | 5 | 3 | 4 | 12
fieldType() |  |  |  |  |  |  | 2 |  |  | 2
fieldTypeSymbol() |  |  |  |  |  |  |  | 2 |  | 2
flags() |  |  |  |  |  |  | 5 |  |  | 5
Total |  |  |  |  |  |  | 12 | 5 | 4 | 21