APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.lang.reflect

public final Enum AccessFlag

extends Enum<AccessFlag>
Class Inheritance
Annotations
@SuppressWarnings:doclint:reference
Imports
java.lang.classfile.ClassModel, .FieldModel, .MethodModel, java.lang.classfile.attribute.InnerClassInfo, .MethodParameterInfo, .ModuleAttribute, .ModuleExportInfo, .ModuleOpenInfo, .ModuleRequireInfo, java.lang.module.ModuleDescriptor, java.util.AbstractSet, .Collection, .Iterator, .List, .Map, .NoSuchElementException, .Objects, .Set, java.util.function.Consumer, .Predicate, jdk.internal.vm.annotation.Stable

Represents a JVM access or module-related flag on a runtime member, such as a class, field, or method.

JVM access and module-related flags are related to, but distinct from Java language modifiers. Some modifiers and access flags have a one-to-one correspondence, such as public. In other cases, some language-level modifiers do not have an access flag, such as sealed (JVMS 4.7.31) and some access flags have no corresponding modifier, such as synthetic.

The values for the constants representing the access and module flags are taken from sections of The Java Virtual Machine Specification including 4.1 (class access and property modifiers), 4.5 (field access and property flags), 4.6 (method access and property flags), 4.7.6 (nested class access and property flags), 4.7.24 (method parameters), and 4.7.25 (module flags and requires, exports, and opens flags).

The mask values for the different access flags are not distinct. Flags are defined for different kinds of JVM structures and the same bit position has different meanings in different contexts. For example, 0x0000_0040 indicates a volatile field but a bridge method; 0x0000_0080 indicates a transient field but a variable arity (varargs) method.

Implementation Specification

The access flag constants are ordered by non-decreasing mask value; that is the mask value of a constant is greater than or equal to the mask value of an immediate neighbor to its (syntactic) left. If new constants are added, this property will be maintained. That implies new constants will not necessarily be added at the end of the existing list.

API Note

The JVM class file format has a new version defined for each new feature release. A new class file version may define new access flags or retire old ones. AccessFlag is intended to model the set of access flags across class file format versions. The range of versions an access flag is recognized is not explicitly indicated in this API. See the current The Java Virtual Machine Specification for details. Unless otherwise indicated, access flags can be assumed to be recognized in the current version.

Since
20
See Also
java.lang.reflect.Modifier, java.lang.module.ModuleDescriptor.Modifier, java.lang.module.ModuleDescriptor.Requires.Modifier, java.lang.module.ModuleDescriptor.Exports.Modifier, java.lang.module.ModuleDescriptor.Opens.Modifier, java.compiler/javax.lang.model.element.Modifier

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
AccessFlag.Location

A location within a class file where flags can be applied.

Field Summary

Modifier and TypeField and Description
public static final AccessFlag
ABSTRACT

The access flag ACC_ABSTRACT, corresponding to the source modifier abstract, with a mask value of "0x0400".

public static final AccessFlag
ANNOTATION

The access flag ACC_ANNOTATION with a mask value of "0x2000".

public static final AccessFlag
BRIDGE

The access flag ACC_BRIDGE with a mask value of "0x0040"

private static final AccessFlag[]
public static final AccessFlag
ENUM

The access flag ACC_ENUM with a mask value of "0x4000".

private static final AccessFlag[]
public static final AccessFlag
FINAL

The access flag ACC_FINAL, corresponding to the source modifier final, with a mask value of "0x0010".

private final List<Map.Entry<ClassFileFormatVersion, Set<AccessFlag.Location>>>
private static final AccessFlag[]
public static final AccessFlag
INTERFACE

The access flag ACC_INTERFACE with a mask value of 0x0200.

private final Set<AccessFlag.Location>
public static final AccessFlag
MANDATED

The access flag ACC_MANDATED with a mask value of "0x8000".

private final int
private static final AccessFlag[]
private static final AccessFlag[]
public static final AccessFlag
MODULE

The access flag ACC_MODULE with a mask value of 0x8000.

private static final AccessFlag[]
private static final AccessFlag[]
private static final AccessFlag[]
private static final AccessFlag[]
public static final AccessFlag
NATIVE

The access flag ACC_NATIVE, corresponding to the source modifier native, with a mask value of "0x0100".

public static final AccessFlag
OPEN

The module flag ACC_OPEN with a mask value of 0x0020.

public static final AccessFlag
PRIVATE

The access flag ACC_PRIVATE, corresponding to the source modifier private, with a mask value of "0x0002".

public static final AccessFlag
PROTECTED

The access flag ACC_PROTECTED, corresponding to the source modifier protected, with a mask value of "0x0004".

public static final AccessFlag
PUBLIC

The access flag ACC_PUBLIC, corresponding to the source modifier public, with a mask value of "0x0001".

private final boolean
public static final AccessFlag
STATIC

The access flag ACC_STATIC, corresponding to the source modifier static, with a mask value of "0x0008".

public static final AccessFlag
STATIC_PHASE

The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040.

public static final AccessFlag
STRICT

The access flag ACC_STRICT, corresponding to the source modifier strictfp, with a mask value of "0x0800".

public static final AccessFlag
SUPER

The access flag ACC_SUPER with a mask value of 0x0020.

public static final AccessFlag
SYNCHRONIZED

The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of "0x0020".

public static final AccessFlag
SYNTHETIC

The access flag ACC_SYNTHETIC with a mask value of "0x1000".

public static final AccessFlag
TRANSIENT

The access flag ACC_TRANSIENT, corresponding to the source modifier transient, with a mask value of "0x0080".

public static final AccessFlag
TRANSITIVE

The module requires flag ACC_TRANSITIVE with a mask value of 0x0020.

public static final AccessFlag
VARARGS

The access flag ACC_VARARGS with a mask value of "0x0080".

public static final AccessFlag
VOLATILE

The access flag ACC_VOLATILE, corresponding to the source modifier volatile, with a mask value of "0x0040".

Constructor Summary

AccessConstructor and Description
private
AccessFlag(int mask, boolean sourceModifier, Set<AccessFlag.Location> locations, List<Map.Entry<ClassFileFormatVersion, Set<AccessFlag.Location>>> historicalLocations)

Method Summary

Modifier and TypeMethod and Description
private static AccessFlag[]
private static AccessFlag[]
public Set<AccessFlag.Location>

Returns:

locations this flag can be applied to in the current class file format version
locations
()

Returns locations this flag can be applied to in the current class file format version.

public Set<AccessFlag.Location>

Returns:

locations this flag can be applied to in the given class file format version
locations
(ClassFileFormatVersion
the class file format version to use
cffv
)

Returns locations this flag can be applied to in the given class file format version.

public int

Returns:

the corresponding mask for the access flag
mask
()

Returns the corresponding mask for the access flag.

public static Set<AccessFlag>

Returns:

an unmodifiable set of access flags for the given mask value appropriate for the location in the current class file format version
maskToAccessFlags
(int
bit mask of access flags
mask
,
AccessFlag.Location
context to interpret mask value
location
)

Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the current class file format version.

public static Set<AccessFlag>

Returns:

an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version
maskToAccessFlags
(int
bit mask of access flags
mask
,
AccessFlag.Location
context to interpret mask value
location
,
ClassFileFormatVersion
the class file format to interpret mask value
cffv
)

Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version.

public boolean

Returns:

whether or not this flag has a directly corresponding modifier in the Java programming language
sourceModifier
()

Returns whether or not this flag has a directly corresponding modifier in the Java programming language.

private static int
undefinedMask(AccessFlag[] definition, int mask)

public static AccessFlag
public static AccessFlag[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf