Enum Class AccessFlag
- All Implemented Interfaces:
Serializable,Comparable<AccessFlag>,Constable
invalid reference
field
invalid reference
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
) 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 (class access and property modifiers), (field access and property flags), (method access and property flags), (nested class access and property flags), (method parameters), and (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.
- Since:
- 20
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA location within aclassfile where flags can be applied.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe access flagACC_ANNOTATIONwith a mask value of.The access flagACC_BRIDGEwith a mask value ofThe access flagACC_ENUMwith a mask value of.The access flagACC_INTERFACEwith a mask value of0x0200.The access flagACC_MANDATEDwith a mask value of.The access flagACC_MODULEwith a mask value of0x8000.The module flagACC_OPENwith a mask value of0x0020.The module requires flagACC_STATIC_PHASEwith a mask value of0x0040.The access flagACC_SUPERwith a mask value of0x0020.The access flagACC_SYNCHRONIZED, corresponding to the source modifiersynchronized, with a mask value of0x0020.The access flagACC_SYNTHETICwith a mask value of.The module requires flagACC_TRANSITIVEwith a mask value of0x0020.The access flagACC_VARARGSwith a mask value of. -
Method Summary
Modifier and TypeMethodDescriptionReturns locations this flag can be applied to in the current class file format version.Returns locations this flag can be applied to in the given class file format version.intmask()Returns the corresponding mask for the access flag.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 the current class file format version.static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location, ClassFileFormatVersion cffv) Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version.booleanReturns whether or not this flag has a directly corresponding modifier in the Java programming language.static AccessFlagReturns 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.
-
Enum Constant Details
-
PUBLIC
-
PRIVATE
-
PROTECTED
-
STATIC
-
FINAL
-
SUPER
The access flagACC_SUPERwith a mask value of0x0020. -
OPEN
The module flagACC_OPENwith a mask value of0x0020.- See Also:
-
TRANSITIVE
The module requires flagACC_TRANSITIVEwith a mask value of0x0020.- See Also:
-
SYNCHRONIZED
The access flagACC_SYNCHRONIZED, corresponding to the source modifiersynchronized, with a mask value of0x0020. -
STATIC_PHASE
The module requires flagACC_STATIC_PHASEwith a mask value of0x0040.- See Also:
-
VOLATILE
-
BRIDGE
The access flagACC_BRIDGEwith a mask value of- See Also:
-
TRANSIENT
-
VARARGS
The access flagACC_VARARGSwith a mask value of.- See Also:
-
NATIVE
-
INTERFACE
The access flagACC_INTERFACEwith a mask value of0x0200.- See Also:
-
ABSTRACT
-
STRICT
-
SYNTHETIC
The access flagACC_SYNTHETICwith a mask value of.- See Also:
-
ANNOTATION
The access flagACC_ANNOTATIONwith a mask value of.- See Also:
-
ENUM
The access flagACC_ENUMwith a mask value of.- See Also:
-
MANDATED
The access flagACC_MANDATEDwith a mask value of. -
MODULE
The access flagACC_MODULEwith a mask value of0x8000.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- 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 nameNullPointerException- if the argument is null
-
mask
public int mask()Returns the corresponding mask for the access flag. The mask has exactly one bit set and is in the range ofchar.- 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.- Returns:
- whether or not this flag has a directly corresponding modifier in the Java programming language
-
locations
Returns locations this flag can be applied to in the current class file format version.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
Returns locations this flag can be applied to in the given class file format version.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
Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the current class file format version.- Parameters:
mask- bit mask of access flagslocation- 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 formatNullPointerException- iflocationisnull
-
maskToAccessFlags
public static Set<AccessFlag> maskToAccessFlags(int mask, AccessFlag.Location location, ClassFileFormatVersion cffv) Returns an unmodifiable set of access flags for the given mask value appropriate for the location in the given class file format version.- Parameters:
mask- bit mask of access flagslocation- context to interpret mask valuecffv- 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 formatNullPointerException- iflocationorcffvisnull- Since:
- 25
-