APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface FieldModel

extends CompoundElement<FieldElement>, AttributedElement, ClassElement
permits Model, FieldImpl
Known Direct Implementers
jdk.internal.classfile.impl.BufferedFieldBuilder.Model, jdk.internal.classfile.impl.FieldImpl
Imports
java.lang.classfile.constantpool.Utf8Entry, java.lang.constant.ClassDesc, java.lang.reflect.AccessFlag, java.util.Optional, java.util.function.Consumer, jdk.internal.classfile.impl.BufferedFieldBuilder, .FieldImpl, .Util

Models a field. A field can be viewed as a composition of FieldElements, or by random access 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 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.

Since
24
Java Virtual Machine Specification
4.5 Fields
See Also
ClassModel#fields(), FieldTransform

Method Summary

Modifier and TypeMethod and Description
public Utf8Entry

Returns:

the name of this field
fieldName
()

Returns the name of this field.

public Utf8Entry

Returns:

the field descriptor string of this field
fieldType
()

Returns the field descriptor string of this field.

public default ClassDesc

Returns:

the field type, as a symbolic descriptor
fieldTypeSymbol
()

Returns the field type, as a symbolic descriptor.

public AccessFlags

Returns:

the access flags
flags
()

Returns the access flags.

public Optional<ClassModel>

Returns:

the class model this field is a member of, if known
parent
()

Returns the class model this field is a member of, if known.

Inherited from java.lang.classfile.AttributedElement:
attributesfindAttributefindAttributes
Inherited from java.lang.classfile.CompoundElement:
elementListelementStreamforEachiteratortoDebugString

Method Detail

fieldNameback to summary
public Utf8Entry fieldName()

Returns the name of this field.

Returns:Utf8Entry

the name of this field

fieldTypeback to summary
public Utf8Entry fieldType()

Returns the field descriptor string of this field.

Returns:Utf8Entry

the field descriptor string of this field

fieldTypeSymbolback to summary
public default ClassDesc fieldTypeSymbol()

Returns the field type, as a symbolic descriptor.

Returns:ClassDesc

the field type, as a symbolic descriptor

flagsback to summary
public AccessFlags flags()

Returns the access flags.

Returns:AccessFlags

the access flags

See Also
AccessFlag.Location#FIELD
parentback to summary
public Optional<ClassModel> parent()

Returns the class model this field is a member of, if known.

Returns:Optional<ClassModel>

the class model this field is a member of, if known