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 ModuleAttribute
- Since:
- 24
- See Also:
- 
Nested Class SummaryNested Classes
- 
Method SummaryModifier and TypeMethodDescriptionexports()Returns the packages exported by this module.default booleanhas(AccessFlag flag) Tests presence of module flag.default Set<AccessFlag> Returns the module flags of the module, as a set of enum constants.intReturns 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 ModuleAttributeof(ModuleEntry moduleName, int moduleFlags, Utf8Entry moduleVersion, Collection<ModuleRequireInfo> requires, Collection<ModuleExportInfo> exports, Collection<ModuleOpenInfo> opens, Collection<ClassEntry> uses, Collection<ModuleProvideInfo> provides) Returns aModuleattribute.static ModuleAttributeof(ModuleEntry moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModuleattribute.static ModuleAttributeof(ModuleDesc moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModuleattribute.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.AttributeattributeMapper, attributeName
- 
Method Details- 
moduleName
- 
moduleFlagsMaskint moduleFlagsMask()Returns the module flags of the module, as a bit mask. It is in the range of unsigned short,[0, 0xFFFF].- Returns:
- the module flags of the module, as a bit mask
- See Also:
 
- 
moduleFlagsReturns 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:
 
- 
hasTests presence of module flag.- Parameters:
- flag- the module flag
- Returns:
- true if the flag is set
- See Also:
 
- 
moduleVersion
- 
requiresList<ModuleRequireInfo> requires()Returns the modules required by this module.- Returns:
- the modules required by this module
- See Also:
 
- 
exportsList<ModuleExportInfo> exports()Returns the packages exported by this module.- Returns:
- the packages exported by this module
- See Also:
 
- 
opensList<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(java.lang.Class<?>, java.lang.invoke.MethodHandles.Lookup)for more details.
- Returns:
- the packages opened by this module
- See Also:
 
- 
usesList<ClassEntry> uses()Returns the services used by this module. Services may be discovered viaServiceLoader.- Returns:
- the services used by this module
- See Also:
 
- 
providesList<ModuleProvideInfo> provides()Returns the service implementations provided by this module.- Returns:
- the service implementations provided by this module
- See Also:
 
- 
ofstatic ModuleAttribute of(ModuleEntry moduleName, int moduleFlags, Utf8Entry moduleVersion, Collection<ModuleRequireInfo> requires, Collection<ModuleExportInfo> exports, Collection<ModuleOpenInfo> opens, Collection<ClassEntry> uses, Collection<ModuleProvideInfo> provides) Returns aModuleattribute.- Parameters:
- moduleName- the module name
- moduleFlags- the module flags
- moduleVersion- the module version, may be- null
- requires- the required packages
- exports- the exported packages
- opens- the opened packages
- uses- the consumed services
- provides- the provided services
- Returns:
- a Moduleattribute
 
- 
ofstatic ModuleAttribute of(ModuleDesc moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModuleattribute.- Parameters:
- moduleName- the module name
- attrHandler- a handler that receives a- ModuleAttribute.ModuleAttributeBuilder
- Returns:
- a Moduleattribute
 
- 
ofstatic ModuleAttribute of(ModuleEntry moduleName, Consumer<ModuleAttribute.ModuleAttributeBuilder> attrHandler) Returns aModuleattribute.- Parameters:
- moduleName- the module name
- attrHandler- a handler that receives a- ModuleAttribute.ModuleAttributeBuilder
- Returns:
- a Moduleattribute
 
 
-