Interface ModuleAttribute
- All Superinterfaces:
Attribute<ModuleAttribute>, ClassElement, ClassFileElement
Models the
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.
- See Java Virtual Machine Specification:
-
4.7.25 The
Module
Attribute - Since:
- 24
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionexports()
Returns the packages exported by this module.default boolean
has
(AccessFlag flag) Tests presence of module flag.default Set
<AccessFlag> Returns the module flags of the module, as a set of enum constants.int
Returns 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 inherited from interface Attribute
attributeMapper, attributeName
-
Method Details
-
moduleName
-
moduleFlagsMask
int moduleFlagsMask()Returns the module flags of the module, as a bit mask.- Returns:
- the module flags of the module, as a bit mask
- See Also:
-
moduleFlags
Returns the module flags of the module, as a set of enum constants.- Returns:
- the module flags of the module, as a set of enum constants
- Throws:
IllegalArgumentException
- if the flags mask has any undefined bit set- See Also:
-
has
Tests presence of module flag.- Parameters:
flag
- the module flag- Returns:
- true if the flag is set
- See Also:
-
moduleVersion
-
requires
List<ModuleRequireInfo> requires()Returns the modules required by this module.- Returns:
- the modules required by this module
- See Also:
-
exports
List<ModuleExportInfo> exports()Returns the packages exported by this module.- Returns:
- the packages exported by this module
- See Also:
-
opens
List<ModuleOpenInfo> opens()Returns the packages opened by this module.- API Note:
- Opening a package to another module allows that other module to gain
the same full privilege access as members in this module. See
MethodHandles.privateLookupIn(Class, MethodHandles.Lookup)
for more details. - Returns:
- the packages opened by this module
- See Also:
-
uses
List<ClassEntry> uses()Returns the services used by this module. Services may be discovered viaServiceLoader
.- Returns:
- the services used by this module
- See Also:
-
provides
List<ModuleProvideInfo> provides()Returns the service implementations provided by this module.- Returns:
- the service implementations provided by this module
- See Also:
-
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 version, may benull
requires
- 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
-