APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface FieldBuilder

extends ClassFileBuilder<FieldElement, FieldBuilder>
permits TerminalFieldBuilder, ChainedFieldBuilder
Known Direct Subinterfaces
jdk.internal.classfile.impl.TerminalFieldBuilder
Known Direct Implementers
jdk.internal.classfile.impl.ChainedFieldBuilder
Imports
java.lang.constant.ClassDesc, java.lang.reflect.AccessFlag, java.util.function.Consumer, jdk.internal.classfile.impl.AccessFlagsImpl, .ChainedFieldBuilder, .TerminalFieldBuilder

A builder for fields. The main way to obtain a field builder is via ClassBuilder#withField(String, ClassDesc, Consumer). The access flag overload is useful if no attribute needs to be configured, skipping the handler.

Refer to ClassFileBuilder for general guidance and caution around the use of builders for structures in the class file format.

Since
24
See Also
ClassBuilder#withField(String, ClassDesc, Consumer), FieldModel, FieldTransform

Method Summary

Modifier and TypeMethod and Description
public default FieldBuilder

Returns:

this builder
withFlags
(int
the access flags, as a bit mask
flags
)

Sets the field access flags.

public default FieldBuilder

Returns:

this builder
withFlags
(AccessFlag...
the access flags, as a bit mask
flags
)

Sets the field access flags.

Inherited from java.lang.classfile.ClassFileBuilder:
acceptconstantPooltransformwith

Method Detail

withFlagsback to summary
public default FieldBuilder withFlags(int flags)

Sets the field access flags.

Parameters
flags:int

the access flags, as a bit mask

Returns:FieldBuilder

this builder

Exceptions
IllegalArgumentException:
if flags is not u2
See Also
AccessFlags, AccessFlag.Location#FIELD, ClassBuilder#withField(String, ClassDesc, int)
withFlagsback to summary
public default FieldBuilder withFlags(AccessFlag... flags)

Sets the field access flags.

Parameters
flags:AccessFlag[]

the access flags, as a bit mask

Returns:FieldBuilder

this builder

Exceptions
IllegalArgumentException:
if any flag cannot be applied to the AccessFlag.Location#FIELD location
See Also
AccessFlags, AccessFlag.Location#FIELD, ClassBuilder#withField(String, ClassDesc, int)