# Interface ModulePackagesAttribute

All Superinterfaces:
  `Attribute<ModulePackagesAttribute>`, `ClassElement`, `ClassFileElement`

public sealed interface ModulePackagesAttribute extends Attribute<ModulePackagesAttribute>, ClassElement
Models the `ModulePackages` attribute (JVMS 4.7.26), which can appear on classes that represent module descriptors to indicate packages in the module used by the module descriptor.

This attribute only appears on classes, and does not permit multiple instances in a class. It has a data dependency on the constant pool.

The attribute was introduced in the Java SE Platform version 9, major version 53.

See Java Virtual Machine Specification:
  4.7.26 The `ModulePackages` Attribute
Since:
  24
See Also:
  - `Attributes.modulePackages()`
  - `ModuleDescriptor.packages()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ModulePackagesAttribute`
  `of(PackageEntry... packages)`
  Returns a `ModulePackages` attribute.
  `static ModulePackagesAttribute`
  `of(List<PackageEntry> packages)`
  Returns a `ModulePackages` attribute.
  `static ModulePackagesAttribute`
  `ofNames(PackageDesc... packages)`
  Returns a `ModulePackages` attribute.
  `static ModulePackagesAttribute`
  `ofNames(List<PackageDesc> packages)`
  Returns a `ModulePackages` attribute.
  `List<PackageEntry>`
  `packages()`
  Returns the packages used by the module descriptor.

  ### Methods declared in interface java.lang.classfile.Attribute

  `attributeMapper, attributeName`

- ## Method Details

  - ### packages

    List<PackageEntry> packages()
    Returns the packages used by the module descriptor. This must include all packages opened or exported by the module, as well as the packages of any service providers, and the package for the main class.
    Returns:
      the packages used by the module descriptor

  - ### of

    static ModulePackagesAttribute of(List<PackageEntry> packages)
    Returns a `ModulePackages` attribute.
    Parameters:
      `packages` - the packages
    Returns:
      a `ModulePackages` attribute

  - ### of

    static ModulePackagesAttribute of(PackageEntry... packages)
    Returns a `ModulePackages` attribute.
    Parameters:
      `packages` - the packages
    Returns:
      a `ModulePackages` attribute

  - ### ofNames

    static ModulePackagesAttribute ofNames(List<PackageDesc> packages)
    Returns a `ModulePackages` attribute.
    Parameters:
      `packages` - the packages
    Returns:
      a `ModulePackages` attribute

  - ### ofNames

    static ModulePackagesAttribute ofNames(PackageDesc... packages)
    Returns a `ModulePackages` attribute.
    Parameters:
      `packages` - the packages
    Returns:
      a `ModulePackages` attribute