Attribute<ModuleAttribute>, ClassElement, ClassFileElementpublic sealed interface ModuleAttribute extends Attribute<ModuleAttribute>, ClassElement
Module attribute (JVMS 4.7.25), which always appears on classes that represent module descriptors. 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.
Module Attribute| Modifier and Type | Interface | Description |
|---|---|---|
static interface |
ModuleAttribute.ModuleAttributeBuilder |
A builder for Module attributes. |
| Modifier and Type | Method | Description |
|---|---|---|
List |
exports() |
Returns the packages exported by this module. |
default boolean |
has |
Tests presence of module flag. |
default Set |
moduleFlags() |
Returns the module flags of the module, as a set of enum constants. |
int |
moduleFlagsMask() |
Returns the module flags of the module, as a bit mask. |
ModuleEntry |
moduleName() |
Returns the name of the module. |
Optional |
moduleVersion() |
Returns the version of the module, if present. |
static ModuleAttribute |
of |
Returns a Module attribute. |
static ModuleAttribute |
of |
Returns a Module attribute. |
static ModuleAttribute |
of |
Returns a Module attribute. |
List |
opens() |
Returns the packages opened by this module. |
List |
provides() |
Returns the service implementations provided by this module. |
List |
requires() |
Returns the modules required by this module. |
List |
uses() |
Returns the services used by this module. |
attributeMapper, attributeName
ModuleEntry moduleName()
int moduleFlagsMask()
[0, 0xFFFF].default Set<AccessFlag> moduleFlags()
IllegalArgumentException - if the flags mask has any undefined bit setdefault boolean has(AccessFlag flag)
flag - the module flagOptional<Utf8Entry> moduleVersion()
List<ModuleRequireInfo> requires()
List<ModuleExportInfo> exports()
List<ModuleOpenInfo> opens()
MethodHandles.privateLookupIn(Class, MethodHandles.Lookup) for more details.List<ClassEntry> uses()
ServiceLoader.List<ModuleProvideInfo> provides()
static ModuleAttribute of(ModuleEntry moduleName, int moduleFlags, Utf8Entry moduleVersion, Collection<ModuleRequireInfo> requires, Collection<ModuleExportInfo> exports, Collection<ModuleOpenInfo> opens, Collection<ClassEntry> uses, Collection<ModuleProvideInfo> provides)
Module attribute.moduleName - the module namemoduleFlags - the module flagsmoduleVersion - the module version, may be null
requires - the required packagesexports - the exported packagesopens - the opened packagesuses - the consumed servicesprovides - the provided servicesModule attributestatic ModuleAttribute of(ModuleDesc moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler)
Module attribute.moduleName - the module nameattrHandler - a handler that receives a ModuleAttribute.ModuleAttributeBuilder
Module attributestatic ModuleAttribute of(ModuleEntry moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler)
Module attribute.moduleName - the module nameattrHandler - a handler that receives a ModuleAttribute.ModuleAttributeBuilder
Module attribute
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/attribute/ModuleAttribute.html