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.
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.Modifier and Type | Class | Description |
---|---|---|
static enum |
AccessFlag.Location |
A location within a class file where flags can be applied. |
Enum.EnumDesc<E extends Enum<E>>
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 |
Modifier and Type | Method | Description |
---|---|---|
Set |
locations() |
Returns kinds of constructs the flag can be applied to in the latest class file format version. |
Set |
locations |
Returns kinds of constructs the flag can be applied to in the given class file format version. |
int |
mask() |
Returns the corresponding integer 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 question. |
boolean |
sourceModifier() |
Returns whether or not the 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. |
public static final AccessFlag PUBLIC
public static final AccessFlag PRIVATE
public static final AccessFlag PROTECTED
public static final AccessFlag STATIC
public static final AccessFlag FINAL
public static final AccessFlag SUPER
ACC_SUPER
with a mask value of
0x0020
.ACC_SUPER
flag as set in every class file (JVMS 4.1).public static final AccessFlag OPEN
ACC_OPEN
with a mask value of
0x0020
.public static final AccessFlag TRANSITIVE
ACC_TRANSITIVE
with a mask value of 0x0020
.public static final AccessFlag SYNCHRONIZED
ACC_SYNCHRONIZED
, corresponding to the source modifier synchronized
, with a mask value of 0x0020
.public static final AccessFlag STATIC_PHASE
ACC_STATIC_PHASE
with a mask value of 0x0040
.public static final AccessFlag VOLATILE
public static final AccessFlag BRIDGE
ACC_BRIDGE
with a mask value of 0x0040
public static final AccessFlag TRANSIENT
public static final AccessFlag VARARGS
ACC_VARARGS
with a mask value of 0x0080
.public static final AccessFlag NATIVE
public static final AccessFlag INTERFACE
ACC_INTERFACE
with a mask value of 0x0200
.public static final AccessFlag ABSTRACT
public static final AccessFlag STRICT
ACC_STRICT
, corresponding to the source modifier strictfp
, with a mask value of 0x0800
.ACC_STRICT
access flag is defined for class file major versions 46 through 60, inclusive (JVMS 4.6), corresponding to Java SE 1.2 through 16.public static final AccessFlag SYNTHETIC
ACC_SYNTHETIC
with a mask value of 0x1000
.public static final AccessFlag ANNOTATION
ACC_ANNOTATION
with a mask value of 0x2000
.public static final AccessFlag ENUM
ACC_ENUM
with a mask value of 0x4000
.public static final AccessFlag MANDATED
ACC_MANDATED
with a mask value of 0x8000
.public static final AccessFlag MODULE
ACC_MODULE
with a mask value of
0x8000
.public static AccessFlag[] values()
public static AccessFlag valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is nullpublic int mask()
public boolean sourceModifier()
public Set<AccessFlag.Location> locations()
public Set<AccessFlag.Location> locations(ClassFileFormatVersion cffv)
cffv
- the class file format version to useNullPointerException
- if the parameter is null
public static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location)
mask
- bit mask of access flagslocation
- context to interpret mask valueIllegalArgumentException
- if the mask contains bit positions not support for the location in question
© 1993, 2023, 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.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/reflect/AccessFlag.html