Interface ModuleAttribute
- All Superinterfaces:
Attribute<ModuleAttribute>
,ClassElement
,ClassFileElement
Models the
Module
attribute (JVMS 4.7.25), which can
appear on classes that represent module descriptors.
Delivered as a ClassElement
when
traversing the elements of a ClassModel
.
The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.
The attribute was introduced in the Java SE Platform version 9.
- Since:
- 24
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder for module attributes. -
Method Summary
Modifier and TypeMethodDescriptionexports()
Returns the packages exported by this module.default boolean
has
(AccessFlag flag) Tests presence of module flagdefault Set
<AccessFlag> Returns the the module flags of the module, as a set of enum constants.int
Returns the the module flags of the module, as a bit mask.Returns the name of the module.Returns the version of the module, if present.static ModuleAttribute
of
(ModuleEntry moduleName, int moduleFlags, Utf8Entry moduleVersion, Collection<ModuleRequireInfo> requires, Collection<ModuleExportInfo> exports, Collection<ModuleOpenInfo> opens, Collection<ClassEntry> uses, Collection<ModuleProvideInfo> provides) Returns aModule
attribute.static ModuleAttribute
of
(ModuleEntry moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModule
attribute.static ModuleAttribute
of
(ModuleDesc moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModule
attribute.opens()
Returns the packages opened by this module.provides()
Returns the service implementations provided by this module.requires()
Returns the modules required by this module.uses()
Returns the services used by this module.Methods declared in interface java.lang.classfile.Attribute
attributeMapper, attributeName
-
Method Details
-
moduleName
-
moduleFlagsMask
int moduleFlagsMask()Returns the the module flags of the module, as a bit mask.- Returns:
- the the module flags of the module, as a bit mask
-
moduleFlags
Returns the the module flags of the module, as a set of enum constants.- Returns:
- the the module flags of the module, as a set of enum constants
-
has
Tests presence of module flag- Parameters:
flag
- the module flag- Returns:
- true if the flag is set
-
moduleVersion
-
requires
List<ModuleRequireInfo> requires()Returns the modules required by this module.- Returns:
- the modules required by this module
-
exports
List<ModuleExportInfo> exports()Returns the packages exported by this module.- Returns:
- the packages exported by this module
-
opens
List<ModuleOpenInfo> opens()Returns the packages opened by this module.- Returns:
- the packages opened by this module
-
uses
List<ClassEntry> uses()Returns the services used by this module. Services may be discovered viaServiceLoader
.- Returns:
- the services used by this module
-
provides
List<ModuleProvideInfo> provides()Returns the service implementations provided by this module.- Returns:
- the service implementations provided by this module
-
of
static ModuleAttribute of(ModuleEntry moduleName, int moduleFlags, Utf8Entry moduleVersion, Collection<ModuleRequireInfo> requires, Collection<ModuleExportInfo> exports, Collection<ModuleOpenInfo> opens, Collection<ClassEntry> uses, Collection<ModuleProvideInfo> provides) Returns aModule
attribute.- Parameters:
moduleName
- the module namemoduleFlags
- the module flagsmoduleVersion
- the module versionrequires
- the required packagesexports
- the exported packagesopens
- the opened packagesuses
- the consumed servicesprovides
- the provided services- Returns:
- a
Module
attribute
-
of
static ModuleAttribute of(ModuleDesc moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModule
attribute.- Parameters:
moduleName
- the module nameattrHandler
- a handler that receives aModuleAttribute.ModuleAttributeBuilder
- Returns:
- a
Module
attribute
-
of
static ModuleAttribute of(ModuleEntry moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModule
attribute.- Parameters:
moduleName
- the module nameattrHandler
- a handler that receives aModuleAttribute.ModuleAttributeBuilder
- Returns:
- a
Module
attribute
-