Enum Class XAccessFlag
- All Implemented Interfaces:
Serializable,Comparable<XAccessFlag>,Constable
This class is similar to Oracle's
AccessFlag default implementation which only exists on Java 20+
It also aims to add a few new APIs such as isSet(int) and isSet(int, XAccessFlag...)- Since:
- 12.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA location within a class file 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_ABSTRACT, corresponding to the source modifierabstract, with a mask value of."0x%04x" Modifier#ABSTRACTThe access flagACC_ANNOTATIONwith a mask value of."0x%04x" Modifier#ANNOTATIONThe access flagACC_BRIDGEwith a mask value of"0x%04x" Modifier#BRIDGEThe access flagACC_ENUMwith a mask value of."0x%04x" Modifier#ENUMThe access flagACC_FINAL, corresponding to the source modifierfinal, with a mask value of."0x%04x" Modifier#FINALThe access flagACC_INTERFACEwith a mask value of0x0200.The access flagACC_MANDATEDwith a mask value of."0x%04x" Modifier#MANDATEDThe access flagACC_MODULEwith a mask value of0x8000.The access flagACC_NATIVE, corresponding to the source modifiernative, with a mask value of."0x%04x" Modifier#NATIVEThe module flagACC_OPENwith a mask value of0x0020.The access flagACC_PRIVATE, corresponding to the source modifierprivate, with a mask value of."0x%04x" Modifier#PRIVATEThe access flagACC_PROTECTED, corresponding to the source modifierprotected, with a mask value of."0x%04x" Modifier#PROTECTEDThe access flagACC_PUBLIC, corresponding to the source modifierpublic, with a mask value of."0x%04x" Modifier#PUBLICThe access flagACC_STATIC, corresponding to the source modifierstatic, with a mask value of."0x%04x" Modifier#STATICThe module requires flagACC_STATIC_PHASEwith a mask value of0x0040.The access flagACC_STRICT, corresponding to the source modifierstrictfp, with a mask value of."0x%04x" Modifier#STRICTThe access flagACC_SUPERwith a mask value of0x0020.The access flagACC_SYNCHRONIZED, corresponding to the source modifiersynchronized, with a mask value of."0x%04x" Modifier#SYNCHRONIZEDThe access flagACC_SYNTHETICwith a mask value of."0x%04x" Modifier#SYNTHETICThe access flagACC_TRANSIENT, corresponding to the source modifiertransient, with a mask value of."0x%04x" Modifier#TRANSIENTThe module requires flagACC_TRANSITIVEwith a mask value of0x0020.The access flagACC_VARARGSwith a mask value of."0x%04x" Modifier#VARARGSThe access flagACC_VOLATILE, corresponding to the source modifiervolatile, with a mask value of."0x%04x" Modifier#VOLATILE -
Method Summary
Modifier and TypeMethodDescriptionintadd(int mod) getModifiers(Object jvm) Gets the modifier of a class, field, method or constructor.booleanisSet(int mod) Checks whether this flag is set usingmask()on the given modifier flag list.static booleanisSet(int mod, XAccessFlag... flags) Checks whether all the given flags are set usingmask()on the given modifier flag list.@NotNull @Unmodifiable Set<XAccessFlag.JVMLocation> Kinds of constructs the flag can be applied to in the latest class file format version (not the current).intmask()The corresponding integer mask for the access flag.static Set<XAccessFlag> of(int mod) intremove(int mod) booleanWhether the flag has a directly corresponding modifier in the Java programming language.static StringtoString(int mod) Prints a string interpretation of the flags that are contained in the given modifier flag list in form ofFlags::(flag1 flag2 flag3 ...)static XAccessFlagReturns the enum constant of this class with the specified name.static XAccessFlag[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PUBLIC
The access flagACC_PUBLIC, corresponding to the source modifierpublic, with a mask value of."0x%04x" Modifier#PUBLIC -
PRIVATE
The access flagACC_PRIVATE, corresponding to the source modifierprivate, with a mask value of."0x%04x" Modifier#PRIVATE -
PROTECTED
The access flagACC_PROTECTED, corresponding to the source modifierprotected, with a mask value of."0x%04x" Modifier#PROTECTED -
STATIC
The access flagACC_STATIC, corresponding to the source modifierstatic, with a mask value of."0x%04x" Modifier#STATIC -
FINAL
The access flagACC_FINAL, corresponding to the source modifierfinal, with a mask value of."0x%04x" Modifier#FINAL -
SUPER
The access flagACC_SUPERwith a mask value of0x0020. -
OPEN
The module flagACC_OPENwith a mask value of0x0020.- Since:
- Java 9
- 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 of."0x%04x" Modifier#SYNCHRONIZED -
STATIC_PHASE
The module requires flagACC_STATIC_PHASEwith a mask value of0x0040.- See Also:
-
VOLATILE
The access flagACC_VOLATILE, corresponding to the source modifiervolatile, with a mask value of."0x%04x" Modifier#VOLATILE -
BRIDGE
The access flagACC_BRIDGEwith a mask value of"0x%04x" Modifier#BRIDGE- Since:
- Java 8
- See Also:
-
TRANSIENT
The access flagACC_TRANSIENT, corresponding to the source modifiertransient, with a mask value of."0x%04x" Modifier#TRANSIENT -
VARARGS
The access flagACC_VARARGSwith a mask value of."0x%04x" Modifier#VARARGS- Since:
- Java 5
- See Also:
-
NATIVE
The access flagACC_NATIVE, corresponding to the source modifiernative, with a mask value of."0x%04x" Modifier#NATIVE -
INTERFACE
The access flagACC_INTERFACEwith a mask value of0x0200.- See Also:
-
ABSTRACT
The access flagACC_ABSTRACT, corresponding to the source modifierabstract, with a mask value of."0x%04x" Modifier#ABSTRACT -
STRICT
The access flagACC_STRICT, corresponding to the source modifierstrictfp, with a mask value of."0x%04x" Modifier#STRICT- Since:
- Java 1.2
-
SYNTHETIC
The access flagACC_SYNTHETICwith a mask value of."0x%04x" Modifier#SYNTHETIC- See Also:
-
ANNOTATION
The access flagACC_ANNOTATIONwith a mask value of."0x%04x" Modifier#ANNOTATION- Since:
- Java 5
- See Also:
-
ENUM
The access flagACC_ENUMwith a mask value of."0x%04x" Modifier#ENUM- Since:
- Java 5
- See Also:
-
MANDATED
The access flagACC_MANDATEDwith a mask value of."0x%04x" Modifier#MANDATED -
MODULE
The access flagACC_MODULEwith a mask value of0x8000.- Since:
- Java 9
-
-
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
The corresponding integer mask for the access flag. -
sourceModifier
@Contract(pure=true) public boolean sourceModifier()Whether the flag has a directly corresponding modifier in the Java programming language.In most cases this'd mean that you can find the flag name inside
Modifieras well. An exception to this rule would beModifier.INTERFACE -
locations
@NotNull @Contract(pure=true) public @NotNull @Unmodifiable Set<XAccessFlag.JVMLocation> locations()Kinds of constructs the flag can be applied to in the latest class file format version (not the current). -
of
- Parameters:
mod- Can beClass.getModifiers()orMember.getModifiers().- See Also:
-
add
@Contract(pure=true) public int add(int mod) -
remove
@Contract(pure=true) public int remove(int mod) -
isSet
@Contract(pure=true) public boolean isSet(int mod) Checks whether this flag is set usingmask()on the given modifier flag list.- Parameters:
mod- Can beClass.getModifiers()orMember.getModifiers().- See Also:
-
isSet
Checks whether all the given flags are set usingmask()on the given modifier flag list.- Parameters:
mod- Can beClass.getModifiers()orMember.getModifiers().- See Also:
-
getModifiers
Gets the modifier of a class, field, method or constructor.- Parameters:
jvm- must be aClassorMember.- Returns:
Optional.empty()if this type doesn't have a modifier.- See Also:
-
toString
Prints a string interpretation of the flags that are contained in the given modifier flag list in form ofFlags::(flag1 flag2 flag3 ...)- Parameters:
mod- Can beClass.getModifiers()orMember.getModifiers().
-