Interface ModuleAttribute.ModuleAttributeBuilder
- Enclosing interface:
ModuleAttribute
public static sealed interface ModuleAttribute.ModuleAttributeBuilder
A builder for
Module attributes.- See Java Virtual Machine Specification:
-
4.7.25 The
ModuleAttribute - Since:
- 24
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionexports(ModuleExportInfo exports) Adds an exported package.exports(PackageDesc pkge, int exportsFlagsMask, ModuleDesc... exportsToModules) Adds an exported package.exports(PackageDesc pkge, Collection<AccessFlag> exportsFlags, ModuleDesc... exportsToModules) Adds an exported package.moduleFlags(int flagsMask) Sets the module flags.moduleFlags(AccessFlag... moduleFlags) Sets the module flags.moduleName(ModuleDesc moduleName) Sets the module name.moduleVersion(String version) Sets the module version, which may benull.opens(ModuleOpenInfo opens) Opens a package.opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules) Opens a package.opens(PackageDesc pkge, Collection<AccessFlag> opensFlags, ModuleDesc... opensToModules) Opens a package.provides(ModuleProvideInfo provides) Declares provision of a service.Declares provision of a service.requires(ModuleRequireInfo requires) Adds module requirement.requires(ModuleDesc module, int requiresFlagsMask, String version) Adds a module requirement.requires(ModuleDesc module, Collection<AccessFlag> requiresFlags, String version) Adds a module requirement.uses(ClassEntry uses) Declares use of a service.Declares use of a service.
-
Method Details
-
moduleName
Sets the module name.- Parameters:
moduleName- the module name- Returns:
- this builder
-
moduleFlags
Sets the module flags.- Parameters:
flagsMask- the module flags- Returns:
- this builder
-
moduleFlags
Sets the module flags.- Parameters:
moduleFlags- the module flags- Returns:
- this builder
- Throws:
IllegalArgumentException- if any flag cannot be applied to theAccessFlag.Location.MODULElocation
-
moduleVersion
Sets the module version, which may benull.- Parameters:
version- the module version, may benull- Returns:
- this builder
-
requires
ModuleAttribute.ModuleAttributeBuilder requires(ModuleDesc module, int requiresFlagsMask, String version) Adds a module requirement.- Parameters:
module- the required modulerequiresFlagsMask- the requires flagsversion- the required module version, may benull- Returns:
- this builder
-
requires
default ModuleAttribute.ModuleAttributeBuilder requires(ModuleDesc module, Collection<AccessFlag> requiresFlags, String version) Adds a module requirement.- Parameters:
module- the required modulerequiresFlags- the requires flagsversion- the required module version, may benull- Returns:
- this builder
- Throws:
IllegalArgumentException- if any flag cannot be applied to theAccessFlag.Location.MODULE_REQUIRESlocation
-
requires
Adds module requirement.- Parameters:
requires- the module require info- Returns:
- this builder
-
exports
ModuleAttribute.ModuleAttributeBuilder exports(PackageDesc pkge, int exportsFlagsMask, ModuleDesc... exportsToModules) Adds an exported package.- Parameters:
pkge- the exported packageexportsFlagsMask- the export flagsexportsToModules- the modules to export to, or empty for an unqualified export- Returns:
- this builder
-
exports
default ModuleAttribute.ModuleAttributeBuilder exports(PackageDesc pkge, Collection<AccessFlag> exportsFlags, ModuleDesc... exportsToModules) Adds an exported package.- Parameters:
pkge- the exported packageexportsFlags- the export flagsexportsToModules- the modules to export to, or empty for an unqualified export- Returns:
- this builder
- Throws:
IllegalArgumentException- if any flag cannot be applied to theAccessFlag.Location.MODULE_EXPORTSlocation
-
exports
Adds an exported package.- Parameters:
exports- the module export info- Returns:
- this builder
-
opens
ModuleAttribute.ModuleAttributeBuilder opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules) Opens a package.- 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. - Parameters:
pkge- the opened packageopensFlagsMask- the open package flagsopensToModules- the modules to open to, or empty for an unqualified open- Returns:
- this builder
-
opens
default ModuleAttribute.ModuleAttributeBuilder opens(PackageDesc pkge, Collection<AccessFlag> opensFlags, ModuleDesc... opensToModules) Opens a package.- 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. - Parameters:
pkge- the opened packageopensFlags- the open package flagsopensToModules- the modules to open to, or empty for an unqualified open- Returns:
- this builder
- Throws:
IllegalArgumentException- if any flag cannot be applied to theAccessFlag.Location.MODULE_OPENSlocation
-
opens
Opens a package.- 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. - Parameters:
opens- the module open info- Returns:
- this builder
-
uses
Declares use of a service.- Parameters:
service- the service class used- Returns:
- this builder
- Throws:
IllegalArgumentException- ifservicerepresents a primitive type
-
uses
Declares use of a service.- Parameters:
uses- the service class used- Returns:
- this builder
-
provides
Declares provision of a service.- Parameters:
service- the service class providedimplClasses- the implementation classes- Returns:
- this builder
- Throws:
IllegalArgumentException- ifserviceor any of theimplClassesrepresents a primitive type
-
provides
Declares provision of a service.- Parameters:
provides- the module provides info- Returns:
- this builder
-