Enum Class AccessFlag

java.lang.Object
java.lang.Enum<AccessFlag>
java.lang.reflect.AccessFlag
All Implemented Interfaces:
Serializable,Comparable<AccessFlag>,Constable

public enumAccessFlagextendsEnum<AccessFlag>
Represents a JVM access or module-related flag on a runtime member, such as aclass,field, ormethod.

JVM access and module-related flags are related to, but distinct from Java languagemodifiers. Some modifiers and access flags have a one-to-one correspondence, such as public. In other cases, some language-level modifiers donot have an access flag, such assealed (JVMS4.7.31) and some access flags have no corresponding modifier, such assynthetic.

The values for the constants representing the access and module flags are taken from sections ofThe Java Virtual Machine Specification including4.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), and4.7.25 (module flags and requires, exports, and opens flags).

Themask values for the different access flags arenot 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 avolatile field but abridge method;0x0000_0080 indicates atransient field but avariable arity (varargs) method.

API Note:
The JVM class file format has anew version defined for each newfeature 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 currentThe Java Virtual Machine Specification for details. Unless otherwise indicated, access flags can be assumed to be recognized in thecurrent version.
Implementation Requirements:
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.
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 declared in class java.lang.Enum

    Enum.EnumDesc<E extendsEnum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The access flagACC_ABSTRACT, corresponding to the source modifierabstract, with a mask value of0x0400.
    The access flagACC_ANNOTATION with a mask value of0x2000.
    The access flagACC_BRIDGE with a mask value of0x0040
    The access flagACC_ENUM with a mask value of0x4000.
    The access flagACC_FINAL, corresponding to the source modifierfinal, with a mask value of0x0010.
    The access flagACC_INTERFACE with a mask value of0x0200.
    The access flagACC_MANDATED with a mask value of0x8000.
    The access flagACC_MODULE with a mask value of 0x8000.
    The access flagACC_NATIVE, corresponding to the source modifiernative, with a mask value of0x0100.
    The module flagACC_OPEN with a mask value of 0x0020.
    The access flagACC_PRIVATE, corresponding to the source modifierprivate, with a mask value of0x0002.
    The access flagACC_PROTECTED, corresponding to the source modifierprotected, with a mask value of0x0004.
    The access flagACC_PUBLIC, corresponding to the source modifierpublic, with a mask value of0x0001.
    The access flagACC_STATIC, corresponding to the source modifierstatic, with a mask value of0x0008.
    The module requires flagACC_STATIC_PHASE with a mask value of0x0040.
    The access flagACC_STRICT, corresponding to the source modifierstrictfp, with a mask value of0x0800.
    The access flagACC_SUPER with a mask value of 0x0020.
    The access flagACC_SYNCHRONIZED, corresponding to the source modifiersynchronized, with a mask value of0x0020.
    The access flagACC_SYNTHETIC with a mask value of0x1000.
    The access flagACC_TRANSIENT, corresponding to the source modifiertransient, with a mask value of0x0080.
    The module requires flagACC_TRANSITIVE with a mask value of0x0020.
    The access flagACC_VARARGS with a mask value of0x0080.
    The access flagACC_VOLATILE, corresponding to the source modifiervolatile, with a mask value of0x0040.
  • 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.
    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.
    Returns the enum constant of this class with the specified name.
    staticAccessFlag[]
    Returns an array containing the constants of this enum class, inthe order they are declared.

    Methods declared in class java.lang.Object

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

    • PUBLIC

      public static final AccessFlag PUBLIC
      The access flagACC_PUBLIC, corresponding to the source modifierpublic, with a mask value of0x0001.
    • PRIVATE

      public static final AccessFlag PRIVATE
      The access flagACC_PRIVATE, corresponding to the source modifierprivate, with a mask value of0x0002.
    • PROTECTED

      public static final AccessFlag PROTECTED
      The access flagACC_PROTECTED, corresponding to the source modifierprotected, with a mask value of0x0004.
    • STATIC

      public static final AccessFlag STATIC
      The access flagACC_STATIC, corresponding to the source modifierstatic, with a mask value of0x0008.
    • FINAL

      public static final AccessFlag FINAL
      The access flagACC_FINAL, corresponding to the source modifierfinal, with a mask value of0x0010.
    • SUPER

      public static final AccessFlag SUPER
      The access flagACC_SUPER with a mask value of 0x0020.
      API Note:
      In Java SE 8 and above, the JVM treats theACC_SUPER flag as set in every class file (JVMS4.1).
    • OPEN

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

      public static final AccessFlag TRANSITIVE
      The module requires flagACC_TRANSITIVE with a mask value of0x0020.
      See Also:
    • SYNCHRONIZED

      public static final AccessFlag SYNCHRONIZED
      The access flagACC_SYNCHRONIZED, corresponding to the source modifiersynchronized, with a mask value of0x0020.
    • STATIC_PHASE

      public static final AccessFlag STATIC_PHASE
      The module requires flagACC_STATIC_PHASE with a mask value of0x0040.
      See Also:
    • VOLATILE

      public static final AccessFlag VOLATILE
      The access flagACC_VOLATILE, corresponding to the source modifiervolatile, with a mask value of0x0040.
    • BRIDGE

      public static final AccessFlag BRIDGE
      The access flagACC_BRIDGE with a mask value of0x0040
      See Also:
    • TRANSIENT

      public static final AccessFlag TRANSIENT
      The access flagACC_TRANSIENT, corresponding to the source modifiertransient, with a mask value of0x0080.
    • VARARGS

      public static final AccessFlag VARARGS
      The access flagACC_VARARGS with a mask value of0x0080.
      See Also:
    • NATIVE

      public static final AccessFlag NATIVE
      The access flagACC_NATIVE, corresponding to the source modifiernative, with a mask value of0x0100.
    • INTERFACE

      public static final AccessFlag INTERFACE
      The access flagACC_INTERFACE with a mask value of0x0200.
      See Also:
    • ABSTRACT

      public static final AccessFlag ABSTRACT
      The access flagACC_ABSTRACT, corresponding to the source modifierabstract, with a mask value of0x0400.
    • STRICT

      public static final AccessFlag STRICT
      The access flagACC_STRICT, corresponding to the source modifierstrictfp, with a mask value of0x0800.
      API Note:
      TheACC_STRICT access flag is defined for class file major versions 46 through 60, inclusive (JVMS4.6), corresponding to Java SE 1.2 through 16.
    • SYNTHETIC

      public static final AccessFlag SYNTHETIC
      The access flagACC_SYNTHETIC with a mask value of0x1000.
      See Also:
    • ANNOTATION

      public static final AccessFlag ANNOTATION
      The access flagACC_ANNOTATION with a mask value of0x2000.
      See Also:
    • ENUM

      public static final AccessFlag ENUM
      The access flagACC_ENUM with a mask value of0x4000.
      See Also:
    • MANDATED

      public static final AccessFlag MANDATED
      The access flagACC_MANDATED with a mask value of0x8000.
    • MODULE

      public static final AccessFlag MODULE
      The access flagACC_MODULE with a mask value of 0x8000.
  • Method Details

    • values

      public static AccessFlag[] values()
      Returns an array containing the constants of this enum class, inthe 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 matchexactly an identifier used to declare anenum 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 isnull
    • 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