InnerClassInfo (Java SE 25 & JDK 25)
Description: declaration: module: java.base, package: java.lang.classfile.attribute, interface: InnerClassInfo
Keywords: java.lang.classfile.attribute.InnerClassInfo interface

# Interface InnerClassInfo

public sealed interface InnerClassInfo
Models a single entry in the `InnerClassesAttribute`.

See Java Virtual Machine Specification:
  4.7.6 The `InnerClasses` Attribute
Since:
  24
See Also:
  - `InnerClassesAttribute.classes()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default Set<AccessFlag>`
  `flags()`
  Returns a set of flag enums denoting access permissions and properties of the nested class.
  `int`
  `flagsMask()`
  Returns a bit mask of flags denoting access permissions and properties of the inner class.
  `default boolean`
  `has(AccessFlag flag)`
  Returns whether a specific access flag is set.
  `ClassEntry`
  `innerClass()`
  Returns the nested class described by this entry.
  `Optional<Utf8Entry>`
  `innerName()`
  Returns the simple name of this class, or empty if this class is anonymous.
  `static InnerClassInfo`
  `of(ClassEntry innerClass, Optional<ClassEntry> outerClass, Optional<Utf8Entry> innerName, int flags)`
  Returns a nested class description.
  `static InnerClassInfo`
  `of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, int flags)`
  Returns a nested class description.
  `static InnerClassInfo`
  `of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, AccessFlag... flags)`
  Returns a nested class description.
  `Optional<ClassEntry>`
  `outerClass()`
  Returns the class or interface of which this class is a member, if it is a member of a class or interface.

- ## Method Details

  - ### innerClass

    ClassEntry innerClass()
    Returns the nested class described by this entry.
    Returns:
      the nested class described by this entry

  - ### outerClass

    Optional<ClassEntry> outerClass()
    Returns the class or interface of which this class is a member, if it is a member of a class or interface. This may be empty if this class is local or anonymous.
    Returns:
      the class or interface of which this class is a member, if it is a member of a class or interface
    See Also:
      - `Class.getDeclaringClass()`

  - ### innerName

    Optional<Utf8Entry> innerName()
    Returns the simple name of this class, or empty if this class is anonymous.
    Returns:
      the simple name of this class, or empty if this class is anonymous
    See Also:
      - `Class.getSimpleName()`

  - ### flagsMask

    int flagsMask()
    Returns a bit mask of flags denoting access permissions and properties of the inner class. It is in the range of unsigned short, `[0, 0xFFFF]`.
    Returns:
      a bit mask of flags denoting access permissions and properties of the inner class
    See Also:
      - `Class.getModifiers()`
      - `AccessFlag.Location.INNER_CLASS`

  - ### flags

    default Set<AccessFlag> flags()
    Returns a set of flag enums denoting access permissions and properties of the nested class.
    Returns:
      a set of flag enums denoting access permissions and properties of the nested class
    Throws:
      `IllegalArgumentException` - if the flags mask has any undefined bit set
    See Also:
      - `Class.accessFlags()`
      - `AccessFlag.Location.INNER_CLASS`

  - ### has

    default boolean has(AccessFlag flag)
    Returns whether a specific access flag is set.
    Parameters:
      `flag` - the access flag
    Returns:
      whether a specific access flag is set
    See Also:
      - `AccessFlag.Location.INNER_CLASS`

  - ### of

    static InnerClassInfo of(ClassEntry innerClass, Optional<ClassEntry> outerClass, Optional<Utf8Entry> innerName, int flags)
    Returns a nested class description.
    Parameters:
      `innerClass` - the nested class being described
      `outerClass` - the class that has the nested class as a member, if it exists
      `innerName` - the simple name of the nested class, if it is not anonymous
      `flags` - the inner class access flags
    Returns:
      a nested class description

  - ### of

    static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, int flags)
    Returns a nested class description.
    Parameters:
      `innerClass` - the nested class being described
      `outerClass` - the class that has the nested class as a member, if it exists
      `innerName` - the simple name of the nested class, if it is not anonymous
      `flags` - the inner class access flags
    Returns:
      a nested class description
    Throws:
      `IllegalArgumentException` - if `innerClass` or `outerClass` represents a primitive type

  - ### of

    static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, AccessFlag... flags)
    Returns a nested class description.
    Parameters:
      `innerClass` - the nested class being described
      `outerClass` - the class that has the nested class as a member, if it exists
      `innerName` - the name of the nested class, if it is not anonymous
      `flags` - the inner class access flags
    Returns:
      a nested class description
    Throws:
      `IllegalArgumentException` - if `innerClass` or `outerClass` represents a primitive type, or if any flag cannot be applied to the `AccessFlag.Location.INNER_CLASS` location