APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ModulePackagesAttribute

extends Attribute<ModulePackagesAttribute>, ClassElement
permits BoundModulePackagesAttribute, UnboundModulePackagesAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundModulePackagesAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundModulePackagesAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassElement, .ClassFile, .ClassModel, java.lang.classfile.constantpool.PackageEntry, java.lang.constant.PackageDesc, java.lang.module.ModuleDescriptor, java.util.Arrays, .List, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

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.

Since
24
Java Virtual Machine Specification
4.7.26 The ModulePackages Attribute
See Also
Attributes#modulePackages(), ModuleDescriptor#packages()

Method Summary

Modifier and TypeMethod and Description
public static ModulePackagesAttribute

Returns:

a ModulePackages attribute
of
(List<PackageEntry>
the packages
packages
)

Returns a ModulePackages attribute.

public static ModulePackagesAttribute

Returns:

a ModulePackages attribute
of
(PackageEntry...
the packages
packages
)

Returns a ModulePackages attribute.

public static ModulePackagesAttribute

Returns:

a ModulePackages attribute
ofNames
(List<PackageDesc>
the packages
packages
)

Returns a ModulePackages attribute.

public static ModulePackagesAttribute

Returns:

a ModulePackages attribute
ofNames
(PackageDesc...
the packages
packages
)

Returns a ModulePackages attribute.

public List<PackageEntry>

Returns:

the packages used by the module descriptor
packages
()

Returns the packages used by the module descriptor.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

ofback to summary
public static ModulePackagesAttribute of(List<PackageEntry> packages)

Returns a ModulePackages attribute.

Parameters
packages:List<PackageEntry>

the packages

Returns:ModulePackagesAttribute

a ModulePackages attribute

Exceptions
IllegalArgumentException:
if the number of packages exceeds the limit of u2
ofback to summary
public static ModulePackagesAttribute of(PackageEntry... packages)

Returns a ModulePackages attribute.

Parameters
packages:PackageEntry[]

the packages

Returns:ModulePackagesAttribute

a ModulePackages attribute

Exceptions
IllegalArgumentException:
if the number of packages exceeds the limit of u2
ofNamesback to summary
public static ModulePackagesAttribute ofNames(List<PackageDesc> packages)

Returns a ModulePackages attribute.

Parameters
packages:List<PackageDesc>

the packages

Returns:ModulePackagesAttribute

a ModulePackages attribute

Exceptions
IllegalArgumentException:
if the number of packages exceeds the limit of u2
ofNamesback to summary
public static ModulePackagesAttribute ofNames(PackageDesc... packages)

Returns a ModulePackages attribute.

Parameters
packages:PackageDesc[]

the packages

Returns:ModulePackagesAttribute

a ModulePackages attribute

Exceptions
IllegalArgumentException:
if the number of packages exceeds the limit of u2
packagesback to summary
public 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:List<PackageEntry>

the packages used by the module descriptor