AccessFlags (Java SE 23 & JDK 23)
Description: declaration: module: java.base, package: java.lang.classfile, interface: AccessFlags
Keywords: java.lang.classfile.AccessFlags interface

# Interface AccessFlags

All Superinterfaces:
  `ClassElementPREVIEW`, `ClassFileElementPREVIEW`, `FieldElementPREVIEW`, `MethodElementPREVIEW`

public sealed interface AccessFlags extends ClassElementPREVIEW, MethodElementPREVIEW, FieldElementPREVIEW
`AccessFlags` is a preview API of the Java platform.
Programs can only use `AccessFlags` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models the access flags for a class, method, or field. Delivered as a `ClassElement`PREVIEW, `FieldElement`PREVIEW, or `MethodElement`PREVIEW when traversing the corresponding model type.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Set<AccessFlag>`
  `flags()`
  Returns the access flags.
  `int`
  `flagsMask()`
  Returns the access flags, as a bit mask.
  `boolean`
  `has(AccessFlag flag)`
  Returns whether the specified flag is present.
  `AccessFlag.Location`
  `location()`
  Returns the classfile location for this element, which is either class, method, or field.
  `static AccessFlagsPREVIEW`
  `ofClass(int mask)`
  Returns an AccessFlagsPREVIEW for a class.
  `static AccessFlagsPREVIEW`
  `ofClass(AccessFlag... flags)`
  Returns an AccessFlagsPREVIEW for a class.
  `static AccessFlagsPREVIEW`
  `ofField(int mask)`
  Returns an AccessFlagsPREVIEW for a field.
  `static AccessFlagsPREVIEW`
  `ofField(AccessFlag... flags)`
  Returns an AccessFlagsPREVIEW for a field.
  `static AccessFlagsPREVIEW`
  `ofMethod(int mask)`
  Returns an AccessFlagsPREVIEW for a method.
  `static AccessFlagsPREVIEW`
  `ofMethod(AccessFlag... flags)`
  Returns an AccessFlagsPREVIEW for a method.

- ## Method Details

  - ### flagsMask

    int flagsMask()
    Returns the access flags, as a bit mask.
    Returns:
      the access flags, as a bit mask

  - ### flags

    Set<AccessFlag> flags()
    Returns the access flags.
    Returns:
      the access flags

  - ### has

    boolean has(AccessFlag flag)
    Returns whether the specified flag is present. The specified flag should be a valid flag for the classfile location associated with this element otherwise false is returned.
    Parameters:
      `flag` - the flag to test
    Returns:
      whether the specified flag is present

  - ### location

    AccessFlag.Location location()
    Returns the classfile location for this element, which is either class, method, or field.
    Returns:
      the classfile location for this element, which is either class, method, or field

  - ### ofClass

    static AccessFlagsPREVIEW ofClass(int mask)
    Returns an AccessFlagsPREVIEW for a class.
    Parameters:
      `mask` - the flags to be set, as a bit mask
    Returns:
      an AccessFlagsPREVIEW for a class

  - ### ofClass

    static AccessFlagsPREVIEW ofClass(AccessFlag... flags)
    Returns an AccessFlagsPREVIEW for a class.
    Parameters:
      `flags` - the flags to be set
    Returns:
      an AccessFlagsPREVIEW for a class

  - ### ofField

    static AccessFlagsPREVIEW ofField(int mask)
    Returns an AccessFlagsPREVIEW for a field.
    Parameters:
      `mask` - the flags to be set, as a bit mask
    Returns:
      an AccessFlagsPREVIEW for a field

  - ### ofField

    static AccessFlagsPREVIEW ofField(AccessFlag... flags)
    Returns an AccessFlagsPREVIEW for a field.
    Parameters:
      `flags` - the flags to be set
    Returns:
      an AccessFlagsPREVIEW for a field

  - ### ofMethod

    static AccessFlagsPREVIEW ofMethod(int mask)
    Returns an AccessFlagsPREVIEW for a method.
    Parameters:
      `mask` - the flags to be set, as a bit mask
    Returns:
      an AccessFlagsPREVIEW for a method

  - ### ofMethod

    static AccessFlagsPREVIEW ofMethod(AccessFlag... flags)
    Returns an AccessFlagsPREVIEW for a method.
    Parameters:
      `flags` - the flags to be set
    Returns:
      an AccessFlagsPREVIEW for a method