java.lang.Object
java.lang.Enum<AccessFlag>
io.github.dmlloyd.classfile.extras.reflect.AccessFlag
All Implemented Interfaces:
Serializable, Comparable<AccessFlag>, Constable

public enum AccessFlag extends Enum<AccessFlag>
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 ) 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 Classes
    Modifier and Type
    Class
    Description
    static enum 
    A 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 Constants
    Enum Constant
    Description
    The access flag ACC_ABSTRACT, corresponding to the source modifier abstract, with a mask value of {@value "0x%04x" Modifier#ABSTRACT}.
    The access flag ACC_ANNOTATION with a mask value of {@value "0x%04x" Modifier#ANNOTATION}.
    The access flag ACC_BRIDGE with a mask value of {@value "0x%04x" Modifier#BRIDGE}
    The access flag ACC_ENUM with a mask value of {@value "0x%04x" Modifier#ENUM}.
    The access flag ACC_FINAL, corresponding to the source modifier final, with a mask value of {@value "0x%04x" Modifier#FINAL}.
    The access flag ACC_INTERFACE with a mask value of 0x0200.
    The access flag ACC_MANDATED with a mask value of {@value "0x%04x" Modifier#MANDATED}.
    The access flag ACC_MODULE with a mask value of 0x8000.
    The access flag ACC_NATIVE, corresponding to the source modifier native, with a mask value of {@value "0x%04x" Modifier#NATIVE}.
    The module flag ACC_OPEN with a mask value of 0x0020.
    The access flag ACC_PRIVATE, corresponding to the source modifier private, with a mask value of {@value "0x%04x" Modifier#PRIVATE}.
    The access flag ACC_PROTECTED, corresponding to the source modifier protected, with a mask value of {@value "0x%04x" Modifier#PROTECTED}.
    The access flag ACC_PUBLIC, corresponding to the source modifier public, with a mask value of {@value "0x%04x" Modifier#PUBLIC}.
    The access flag ACC_STATIC, corresponding to the source modifier static, with a mask value of {@value "0x%04x" Modifier#STATIC}.
    The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040.
    The access flag ACC_STRICT, corresponding to the source modifier strictfp, with a mask value of {@value "0x%04x" Modifier#STRICT}.
    The access flag ACC_SUPER with a mask value of 0x0020.
    The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of {@value "0x%04x" Modifier#SYNCHRONIZED}.
    The access flag ACC_SYNTHETIC with a mask value of {@value "0x%04x" Modifier#SYNTHETIC}.
    The access flag ACC_TRANSIENT, corresponding to the source modifier transient, with a mask value of {@value "0x%04x" Modifier#TRANSIENT}.
    The module requires flag ACC_TRANSITIVE with a mask value of 0x0020.
    The access flag ACC_VARARGS with a mask value of {@value "0x%04x" Modifier#VARARGS}.
    The access flag ACC_VOLATILE, corresponding to the source modifier volatile, with a mask value of {@value "0x%04x" Modifier#VOLATILE}.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns kinds of constructs the flag can be applied to in the latest class file format version.
    Returns kinds of constructs the flag can be applied to in the given class file format version.
    int
    Returns the corresponding integer mask for the access flag.
    static Set<AccessFlag>
    Returns an unmodifiable set of access flags for the given mask value appropriate for the location in question.
    boolean
    Returns whether or not the flag has a directly corresponding modifier in the Java programming language.
    static AccessFlag
    Returns the enum constant of this class with the specified name.
    static AccessFlag[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • PUBLIC

      public static final AccessFlag PUBLIC
      The access flag ACC_PUBLIC, corresponding to the source modifier public, with a mask value of {@value "0x%04x" Modifier#PUBLIC}.
    • PRIVATE

      public static final AccessFlag PRIVATE
      The access flag ACC_PRIVATE, corresponding to the source modifier private, with a mask value of {@value "0x%04x" Modifier#PRIVATE}.
    • PROTECTED

      public static final AccessFlag PROTECTED
      The access flag ACC_PROTECTED, corresponding to the source modifier protected, with a mask value of {@value "0x%04x" Modifier#PROTECTED}.
    • STATIC

      public static final AccessFlag STATIC
      The access flag ACC_STATIC, corresponding to the source modifier static, with a mask value of {@value "0x%04x" Modifier#STATIC}.
    • FINAL

      public static final AccessFlag FINAL
      The access flag ACC_FINAL, corresponding to the source modifier final, with a mask value of {@value "0x%04x" Modifier#FINAL}.
    • SUPER

      public static final AccessFlag SUPER
      The access flag ACC_SUPER with a mask value of 0x0020.
    • OPEN

      public static final AccessFlag OPEN
      The module flag ACC_OPEN with a mask value of 0x0020.
      See Also:
    • TRANSITIVE

      public static final AccessFlag TRANSITIVE
      The module requires flag ACC_TRANSITIVE with a mask value of 0x0020.
      See Also:
    • SYNCHRONIZED

      public static final AccessFlag SYNCHRONIZED
      The access flag ACC_SYNCHRONIZED, corresponding to the source modifier synchronized, with a mask value of {@value "0x%04x" Modifier#SYNCHRONIZED}.
    • STATIC_PHASE

      public static final AccessFlag STATIC_PHASE
      The module requires flag ACC_STATIC_PHASE with a mask value of 0x0040.
      See Also:
    • VOLATILE

      public static final AccessFlag VOLATILE
      The access flag ACC_VOLATILE, corresponding to the source modifier volatile, with a mask value of {@value "0x%04x" Modifier#VOLATILE}.
    • BRIDGE

      public static final AccessFlag BRIDGE
      The access flag ACC_BRIDGE with a mask value of {@value "0x%04x" Modifier#BRIDGE}
      See Also:
    • TRANSIENT

      public static final AccessFlag TRANSIENT
      The access flag ACC_TRANSIENT, corresponding to the source modifier transient, with a mask value of {@value "0x%04x" Modifier#TRANSIENT}.
    • VARARGS

      public static final AccessFlag VARARGS
      The access flag ACC_VARARGS with a mask value of {@value "0x%04x" Modifier#VARARGS}.
      See Also:
    • NATIVE

      public static final AccessFlag NATIVE
      The access flag ACC_NATIVE, corresponding to the source modifier native, with a mask value of {@value "0x%04x" Modifier#NATIVE}.
    • INTERFACE

      public static final AccessFlag INTERFACE
      The access flag ACC_INTERFACE with a mask value of 0x0200.
      See Also:
    • ABSTRACT

      public static final AccessFlag ABSTRACT
      The access flag ACC_ABSTRACT, corresponding to the source modifier abstract, with a mask value of {@value "0x%04x" Modifier#ABSTRACT}.
    • STRICT

      public static final AccessFlag STRICT
      The access flag ACC_STRICT, corresponding to the source modifier strictfp, with a mask value of {@value "0x%04x" Modifier#STRICT}.
    • SYNTHETIC

      public static final AccessFlag SYNTHETIC
      The access flag ACC_SYNTHETIC with a mask value of {@value "0x%04x" Modifier#SYNTHETIC}.
      See Also:
    • ANNOTATION

      public static final AccessFlag ANNOTATION
      The access flag ACC_ANNOTATION with a mask value of {@value "0x%04x" Modifier#ANNOTATION}.
      See Also:
    • ENUM

      public static final AccessFlag ENUM
      The access flag ACC_ENUM with a mask value of {@value "0x%04x" Modifier#ENUM}.
      See Also:
    • MANDATED

      public static final AccessFlag MANDATED
      The access flag ACC_MANDATED with a mask value of {@value "0x%04x" Modifier#MANDATED}.
    • MODULE

      public static final AccessFlag MODULE
      The access flag 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.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AccessFlag valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • mask

      public int mask()
      Returns the corresponding integer mask for the access flag.
      Returns:
      the corresponding integer mask for the access flag
    • sourceModifier

      public boolean sourceModifier()
      Returns whether or not the flag has a directly corresponding modifier in the Java programming language.
      Returns:
      whether or not the flag has a directly corresponding modifier in the Java programming language
    • locations

      public Set<AccessFlag.Location> locations()
      Returns kinds of constructs the flag can be applied to in the latest class file format version.
      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 given class file format version.
      Parameters:
      cffv - the class file format version to use
      Returns:
      kinds of constructs the flag can be applied to in the given class file format version
      Throws:
      NullPointerException - if the parameter is null
    • maskToAccessFlags

      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 - 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 question
      Throws:
      IllegalArgumentException - if the mask contains bit positions not support for the location in question