Enum Class AccessFlag
- All Implemented Interfaces:
Serializable, Comparable<AccessFlag>, Constable
public enum AccessFlag extends Enum<AccessFlag>
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.
- 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.
AccessFlagis 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. - Implementation Requirements:
- 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.
- Since:
- 20
- See Also:
Nested Class Summary
| Modifier and Type | Class | Description |
|---|---|---|
static enum |
AccessFlag.Location |
A location within a class file where flags can be applied. |
Nested classes/interfaces declared in class Enum
Enum.EnumDesc<E> | Modifier and Type | Class | Description |
|---|---|---|
static final class |
Enum.EnumDesc<E extends Enum<E>> |
A nominal descriptor for an enum constant. |
Enum Constant Summary
| Enum Constant | Description |
|---|---|
ABSTRACT |
|
ANNOTATION |
The access flag ACC_ANNOTATION with a mask value of 0x2000. |
BRIDGE |
The access flag ACC_BRIDGE with a mask value of 0x0040
|
ENUM |
The access flag ACC_ENUM with a mask value of 0x4000. |
FINAL |
|
INTERFACE |
The access flag ACC_INTERFACE with a mask value of 0x0200. |
MANDATED |
The access flag ACC_MANDATED with a mask value of 0x8000. |
MODULE |
The access flag ACC_MODULE with a mask value of
0x8000. |
NATIVE |
|
OPEN |
The module flag ACC_OPEN with a mask value of
0x0020. |
PRIVATE |
|
PROTECTED |
|
PUBLIC |
|
STATIC |
|
STATIC_PHASE |
The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040. |
STRICT |
|
SUPER |
The access flag ACC_SUPER with a mask value of
0x0020. |
SYNCHRONIZED |
The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of 0x0020. |
SYNTHETIC |
The access flag ACC_SYNTHETIC with a mask value of 0x1000. |
TRANSIENT |
|
TRANSITIVE |
The module requires flag ACC_TRANSITIVE with a mask value of 0x0020. |
VARARGS |
The access flag ACC_VARARGS with a mask value of 0x0080. |
VOLATILE |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Set |
locations() |
Returns locations this flag can be applied to in the current class file format version. |
Set |
locations |
Returns locations this flag can be applied to in the given class file format version. |
int |
mask() |
Returns the corresponding mask for the access flag. |
static Set |
maskToAccessFlags |
Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the current class file format version. |
static Set |
maskToAccessFlags |
Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version. |
boolean |
sourceModifier() |
Returns whether or not this flag has a directly corresponding modifier in the Java programming language. |
static AccessFlag |
valueOf |
Returns the enum constant of this class with the specified name. |
static AccessFlag[] |
values() |
Returns an array containing the constants of this enum class, in the order they are declared. |
Methods declared in class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf | Modifier and Type | Method | Description |
|---|---|---|
protected final Object |
clone() |
Throws CloneNotSupportedException. |
final int |
compareTo |
Compares this enum with the specified object for order. |
final Optional |
describeConstable() |
Returns an enum descriptor EnumDesc for this instance, if one can be constructed, or an empty Optional if one cannot be. |
final boolean |
equals |
Returns true if the specified object is equal to this enum constant. |
protected final void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization has been deprecated for removal. |
final Class |
getDeclaringClass() |
Returns the Class object corresponding to this enum constant's enum type. |
final int |
hashCode() |
Returns a hash code for this enum constant. |
final String |
name() |
Returns the name of this enum constant, exactly as declared in its enum declaration. |
final int |
ordinal() |
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). |
String |
toString() |
Returns the name of this enum constant, as contained in the declaration. |
static <T extends Enum<T>> |
valueOf |
Returns the enum constant of the specified enum class with the specified name. |
Methods declared in class Object
getClass, notify, notifyAll, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
final Class |
getClass() |
Returns the runtime class of this Object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Enum Constant Details
PUBLIC
PRIVATE
PROTECTED
STATIC
FINAL
SUPER
public static final AccessFlag SUPER
ACC_SUPER with a mask value of
0x0020.- API Note:
- In Java SE 8 and above, the JVM treats the
ACC_SUPERflag as set in every class file (JVMS §4.1).
OPEN
public static final AccessFlag OPEN
ACC_OPEN with a mask value of
0x0020.- See Also:
TRANSITIVE
public static final AccessFlag TRANSITIVE
ACC_TRANSITIVE with a mask value of 0x0020.- See Also:
SYNCHRONIZED
public static final AccessFlag SYNCHRONIZED
ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of 0x0020.STATIC_PHASE
public static final AccessFlag STATIC_PHASE
ACC_STATIC_PHASE with a mask value of 0x0040.- See Also:
VOLATILE
BRIDGE
public static final AccessFlag BRIDGE
ACC_BRIDGE with a mask value of 0x0040
- See Also:
TRANSIENT
VARARGS
public static final AccessFlag VARARGS
ACC_VARARGS with a mask value of 0x0080.- See Also:
NATIVE
INTERFACE
public static final AccessFlag INTERFACE
ACC_INTERFACE with a mask value of 0x0200.- See Also:
ABSTRACT
STRICT
SYNTHETIC
public static final AccessFlag SYNTHETIC
ACC_SYNTHETIC with a mask value of 0x1000.- See Also:
ANNOTATION
public static final AccessFlag ANNOTATION
ACC_ANNOTATION with a mask value of 0x2000.- See Also:
ENUM
public static final AccessFlag ENUM
ACC_ENUM with a mask value of 0x4000.- See Also:
MANDATED
public static final AccessFlag MANDATED
ACC_MANDATED with a mask value of 0x8000.MODULE
public static final AccessFlag MODULE
ACC_MODULE with a mask value of
0x8000.Method Details
values
public static AccessFlag[] values()
- Returns:
- an array containing the constants of this enum class, in the order they are declared
valueOf
public static AccessFlag valueOf(String name)
- Parameters:
-
name- the name of the enum constant to be returned. - Returns:
- the enum constant with the specified name
- Throws:
-
IllegalArgumentException- if this enum class has no constant with the specified name -
NullPointerException- if the argument is null
mask
public int mask()
char.- Returns:
- the corresponding mask for the access flag
sourceModifier
public boolean sourceModifier()
- Returns:
- whether or not this flag has a directly corresponding modifier in the Java programming language
locations
public Set<AccessFlag.Location> locations()
This method returns an empty set if this flag is not defined in the current class file format version.
- Returns:
- locations this flag can be applied to in the current class file format version
locations
public Set<AccessFlag.Location> locations(ClassFileFormatVersion cffv)
This method returns an empty set if this flag is not defined in the given cffv.
- Parameters:
-
cffv- the class file format version to use - Returns:
- locations this flag can be applied to in the given class file format version
- Throws:
-
NullPointerException- if the parameter isnull
maskToAccessFlags
public static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location)
- Parameters:
-
mask- bit mask of access flags -
location- context to interpret mask value - Returns:
- an unmodifiable set of access flags for the given mask value appropriate for the location in the current class file format version
- Throws:
-
IllegalArgumentException- if the mask contains bit positions not defined for the location in the current class file format -
NullPointerException- iflocationisnull
maskToAccessFlags
public static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location, ClassFileFormatVersion cffv)
- Parameters:
-
mask- bit mask of access flags -
location- context to interpret mask value -
cffv- the class file format to interpret mask value - Returns:
- an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version
- Throws:
-
IllegalArgumentException- if the mask contains bit positions not defined for the location in the given class file format -
NullPointerException- iflocationorcffvisnull - Since:
- 25
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.