APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface AccessFlags

extends ClassElement, MethodElement, FieldElement
permits AccessFlagsImpl
Known Direct Implementers
jdk.internal.classfile.impl.AccessFlagsImpl
Imports
java.lang.reflect.AccessFlag, java.util.Set, jdk.internal.classfile.impl.AccessFlagsImpl

Models the access flags for a class, method, or field. The access flags appears exactly once in each class, method, or field; a ClassBuilder and a FieldBuilder chooses an unspecified default value if access flags are not provided, and a MethodBuilder is always created with access flags.

AccessFlags cannot be created via a factory method directly; it can be created with withFlags methods on the respective builders.

A MethodBuilder throws an IllegalArgumentException if it is supplied an AccessFlags object that changes the preexisting ACC_STATIC flag of the builder, because the access flag change may invalidate previously supplied data to the builder.

API Note

The access flags of classes, methods, and fields are modeled as a standalone object to support streaming as elements for ClassFileTransform. Other access flags are not elements of a CompoundElement and thus not modeled by AccessFlags; they provide their own flagsMask, flags, and has methods.

Since
24
See Also
ClassModel#flags(), FieldModel#flags(), MethodModel#flags(), ClassBuilder#withFlags, FieldBuilder#withFlags, MethodBuilder#withFlags

Method Summary

Modifier and TypeMethod and Description
public Set<AccessFlag>

Returns:

the access flags, as a set of flag enums
flags
()

Returns the access flags, as a set of flag enums.

public int

Returns:

the access flags, as a bit mask
flagsMask
()

Returns the access flags, as a bit mask.

public boolean

Returns:

whether the specified flag is set
has
(AccessFlag
the flag to test
flag
)

Returns whether the specified flag is set.

public AccessFlag.Location

Returns:

the class file location for this element, which is either class, method, or field
location
()

Returns the class file location for this element, which is either class, method, or field.

Method Detail

flagsback to summary
public Set<AccessFlag> flags()

Returns the access flags, as a set of flag enums.

Returns:Set<AccessFlag>

the access flags, as a set of flag enums

Exceptions
IllegalArgumentException:
if the flags mask has any undefined bit set
See Also
location()
flagsMaskback to summary
public int flagsMask()

Returns the access flags, as a bit mask. It is a u2 value.

Returns:int

the access flags, as a bit mask

hasback to summary
public boolean has(AccessFlag flag)

Returns whether the specified flag is set. If the specified flag is not available to this location, returns false.

Parameters
flag:AccessFlag

the flag to test

Returns:boolean

whether the specified flag is set

See Also
location()
locationback to summary
public AccessFlag.Location location()

Returns the class file location for this element, which is either class, method, or field.

Returns:AccessFlag.Location

the class file location for this element, which is either class, method, or field

See Also
AccessFlag.Location#CLASS, AccessFlag.Location#FIELD, AccessFlag.Location#METHOD