Top Description Inners Fields Constructors Methods
java.lang.reflect

public final Enum AccessFlag

extends Enum<AccessFlag>
Class Inheritance
Annotations
@SuppressWarnings:doclint:reference
Imports
java.util.Collections, .Objects, .Map, .Set, java.util.function.Function

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
public static enum
AccessFlag.Location

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

private static class

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 final Function<ClassFileFormatVersion, Set<AccessFlag.Location>>
public static final AccessFlag
ENUM

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

public static final AccessFlag
FINAL

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

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
public static final AccessFlag
MODULE

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

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, Function<ClassFileFormatVersion, Set<AccessFlag.Location>> cffvToLocations)

Method Summary

Modifier and TypeMethod and Description
public Set<AccessFlag.Location>

Returns:

kinds of constructs the flag can be applied to in the latest class file format version
locations
()

Returns kinds of constructs the flag can be applied to in the latest class file format version.

public Set<AccessFlag.Location>

Returns:

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

Returns kinds of constructs the flag can be applied to in the given class file format version.

public int

Returns:

the corresponding integer mask for the access flag
mask
()

Returns the corresponding integer 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 question
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 question.

public boolean

Returns:

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

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

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

Field Detail

ABSTRACTback to summary
public static final AccessFlag ABSTRACT

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

ANNOTATIONback to summary
public static final AccessFlag ANNOTATION

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

See Also
Class#isAnnotation()
BRIDGEback to summary
public static final AccessFlag BRIDGE

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

See Also
Method#isBridge()
cffvToLocationsback to summary
private final Function<ClassFileFormatVersion, Set<AccessFlag.Location>> cffvToLocations
ENUMback to summary
public static final AccessFlag ENUM

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

See Also
Class#isEnum()
FINALback to summary
public static final AccessFlag FINAL

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

INTERFACEback to summary
public static final AccessFlag INTERFACE

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

See Also
Class#isInterface()
locationsback to summary
private final Set<AccessFlag.Location> locations
MANDATEDback to summary
public static final AccessFlag MANDATED

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

maskback to summary
private final int mask
MODULEback to summary
public static final AccessFlag MODULE

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

NATIVEback to summary
public static final AccessFlag NATIVE

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

OPENback to summary
public static final AccessFlag OPEN

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

See Also
java.lang.module.ModuleDescriptor#isOpen
PRIVATEback to summary
public static final AccessFlag PRIVATE

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

PROTECTEDback to summary
public static final AccessFlag PROTECTED

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

PUBLICback to summary
public static final AccessFlag PUBLIC

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

sourceModifierback to summary
private final boolean sourceModifier
STATICback to summary
public static final AccessFlag STATIC

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

STATIC_PHASEback to summary
public static final AccessFlag STATIC_PHASE

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

See Also
java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC
STRICTback to summary
public static final AccessFlag STRICT

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

API Note

The 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.

SUPERback to summary
public static final AccessFlag SUPER

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

API Note

In Java SE 8 and above, the JVM treats the ACC_SUPER flag as set in every class file (JVMS 4.1).

SYNCHRONIZEDback to summary
public static final AccessFlag SYNCHRONIZED

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

SYNTHETICback to summary
public static final AccessFlag SYNTHETIC

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

See Also
Class#isSynthetic(), Executable#isSynthetic(), java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC
TRANSIENTback to summary
public static final AccessFlag TRANSIENT

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

TRANSITIVEback to summary
public static final AccessFlag TRANSITIVE

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

See Also
java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
VARARGSback to summary
public static final AccessFlag VARARGS

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

See Also
Executable#isVarArgs()
VOLATILEback to summary
public static final AccessFlag VOLATILE

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

Constructor Detail

AccessFlagback to summary
private AccessFlag(int mask, boolean sourceModifier, Set<AccessFlag.Location> locations, Function<ClassFileFormatVersion, Set<AccessFlag.Location>> cffvToLocations)

Method Detail

locationsback to summary
public Set<AccessFlag.Location> locations()

Returns kinds of constructs the flag can be applied to in the latest class file format version.

Returns:Set<AccessFlag.Location>

kinds of constructs the flag can be applied to in the latest class file format version

locationsback to summary
public Set<AccessFlag.Location> locations(ClassFileFormatVersion cffv)

Returns kinds of constructs the flag can be applied to in the given class file format version.

Parameters
cffv:ClassFileFormatVersion

the class file format version to use

Returns:Set<AccessFlag.Location>

kinds of constructs the flag can be applied to in the given class file format version

Exceptions
NullPointerException:
if the parameter is null
maskback to summary
public int mask()

Returns the corresponding integer mask for the access flag.

Returns:int

the corresponding integer mask for the access flag

maskToAccessFlagsback to summary
public static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location)

Returns an unmodifiable set of access flags for the given mask value appropriate for the location in question.

Parameters
mask:int

bit mask of access flags

location:AccessFlag.Location

context to interpret mask value

Returns:Set<AccessFlag>

an unmodifiable set of access flags for the given mask value appropriate for the location in question

Exceptions
IllegalArgumentException:
if the mask contains bit positions not support for the location in question
sourceModifierback to summary
public boolean sourceModifier()

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

Returns:boolean

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

valueOfback to summary
public static AccessFlag valueOf(String name)
valuesback to summary
public static AccessFlag[] values()
java.lang.reflect back to summary

public final Enum AccessFlag.Location

extends Enum<AccessFlag.Location>
Class Inheritance

A location within a class file where flags can be applied. Note that since these locations represent class file structures rather than language structures many language structures, such as constructors and interfaces, are not present.
Since
20

Field Summary

Modifier and TypeField and Description
public static final AccessFlag.Location
CLASS

Class location.

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

Field location.

public static final AccessFlag.Location
INNER_CLASS

Inner class location.

public static final AccessFlag.Location
METHOD

Method location.

public static final AccessFlag.Location
METHOD_PARAMETER

Method parameter location.

public static final AccessFlag.Location
MODULE

Module location

public static final AccessFlag.Location
MODULE_EXPORTS

Module exports location

public static final AccessFlag.Location
MODULE_OPENS

Module opens location

public static final AccessFlag.Location
MODULE_REQUIRES

Module requires location

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AccessFlag.Location
public static AccessFlag.Location[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLASSback to summary
public static final AccessFlag.Location CLASS

Class location.

Java Virtual Machine Specification
4.1 The ClassFile Structure
EMPTY_SETback to summary
private static final Set<AccessFlag.Location> EMPTY_SET
FIELDback to summary
public static final AccessFlag.Location FIELD

Field location.

Java Virtual Machine Specification
4.5 Fields
INNER_CLASSback to summary
public static final AccessFlag.Location INNER_CLASS

Inner class location.

Java Virtual Machine Specification
4.7.6 The InnerClasses Attribute
METHODback to summary
public static final AccessFlag.Location METHOD

Method location.

Java Virtual Machine Specification
4.6 Method
METHOD_PARAMETERback to summary
public static final AccessFlag.Location METHOD_PARAMETER

Method parameter location.

Java Virtual Machine Specification
4.7.24. The MethodParameters Attribute
MODULEback to summary
public static final AccessFlag.Location MODULE

Module location

Java Virtual Machine Specification
4.7.25. The Module Attribute
MODULE_EXPORTSback to summary
public static final AccessFlag.Location MODULE_EXPORTS

Module exports location

Java Virtual Machine Specification
4.7.25. The Module Attribute
MODULE_OPENSback to summary
public static final AccessFlag.Location MODULE_OPENS

Module opens location

Java Virtual Machine Specification
4.7.25. The Module Attribute
MODULE_REQUIRESback to summary
public static final AccessFlag.Location MODULE_REQUIRES

Module requires location

Java Virtual Machine Specification
4.7.25. The Module Attribute
SET_CLASSback to summary
private static final Set<AccessFlag.Location> SET_CLASS
SET_CLASS_FIELD_INNER_CLASSback to summary
private static final Set<AccessFlag.Location> SET_CLASS_FIELD_INNER_CLASS
SET_CLASS_FIELD_METHODback to summary
private static final Set<AccessFlag.Location> SET_CLASS_FIELD_METHOD
SET_CLASS_FIELD_METHOD_INNER_CLASSback to summary
private static final Set<AccessFlag.Location> SET_CLASS_FIELD_METHOD_INNER_CLASS
SET_CLASS_INNER_CLASSback to summary
private static final Set<AccessFlag.Location> SET_CLASS_INNER_CLASS
SET_CLASS_METHODback to summary
private static final Set<AccessFlag.Location> SET_CLASS_METHOD
SET_CLASS_METHOD_INNER_CLASSback to summary
private static final Set<AccessFlag.Location> SET_CLASS_METHOD_INNER_CLASS
SET_FIELDback to summary
private static final Set<AccessFlag.Location> SET_FIELD
SET_FIELD_METHODback to summary
private static final Set<AccessFlag.Location> SET_FIELD_METHOD
SET_FIELD_METHOD_INNER_CLASSback to summary
private static final Set<AccessFlag.Location> SET_FIELD_METHOD_INNER_CLASS
SET_FINAL_8back to summary
private static final Set<AccessFlag.Location> SET_FINAL_8
SET_MANDATED_9back to summary
private static final Set<AccessFlag.Location> SET_MANDATED_9
SET_METHODback to summary
private static final Set<AccessFlag.Location> SET_METHOD
SET_METHOD_PARAMback to summary
private static final Set<AccessFlag.Location> SET_METHOD_PARAM
SET_MODULEback to summary
private static final Set<AccessFlag.Location> SET_MODULE
SET_MODULE_REQUIRESback to summary
private static final Set<AccessFlag.Location> SET_MODULE_REQUIRES
SET_PUBLIC_1back to summary
private static final Set<AccessFlag.Location> SET_PUBLIC_1
SET_SYNTHETIC_7back to summary
private static final Set<AccessFlag.Location> SET_SYNTHETIC_7
SET_SYNTHETIC_8back to summary
private static final Set<AccessFlag.Location> SET_SYNTHETIC_8
SET_SYNTHETIC_9back to summary
private static final Set<AccessFlag.Location> SET_SYNTHETIC_9

Constructor Detail

Locationback to summary
private Location()

Method Detail

valueOfback to summary
public static AccessFlag.Location valueOf(String name)
valuesback to summary
public static AccessFlag.Location[] values()
java.lang.reflect back to summary

private Class AccessFlag.LocationToFlags

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static Map<AccessFlag.Location, Set<AccessFlag>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

locationToFlagsback to summary
private static Map<AccessFlag.Location, Set<AccessFlag>> locationToFlags

Constructor Detail

LocationToFlagsback to summary
private LocationToFlags()