Class ModuleLayer.Controller
java.lang.Object
java.lang.ModuleLayer.Controller
- Enclosing class:
- ModuleLayer
public static final class ModuleLayer.Controller extends Object
Controls a module layer. The static methods defined by
ModuleLayer
to create module layers return a Controller
that can be used to control modules in the layer. Unless otherwise specified, passing a null
argument to a method in this class causes a NullPointerException
to be thrown.
- API Note:
- Care should be taken with
Controller
objects, they should never be shared with untrusted code. - Since:
- 9
Method Summary
Modifier and Type | Method | Description |
---|---|---|
ModuleLayer.Controller |
addExports |
Updates module source in the layer to export a package to module target . |
ModuleLayer.Controller |
addOpens |
Updates module source in the layer to open a package to module target . |
ModuleLayer.Controller |
addReads |
Updates module source in the layer to read module target . |
ModuleLayer |
layer() |
Returns the layer that this object controls. |
Method Details
layer
public ModuleLayer layer()
Returns the layer that this object controls.
- Returns:
- the module layer
addReads
public ModuleLayer.Controller addReads(Module source, Module target)
Updates module
source
in the layer to read module target
. This method is a no-op if source
already reads target
.- Implementation Note:
-
Read edges added by this method are weak and do not prevent
target
from being GC'ed whensource
is strongly reachable. - Parameters:
-
source
- The source module -
target
- The target module to read - Returns:
- This controller
- Throws:
-
IllegalArgumentException
- Ifsource
is not in the module layer - See Also:
addExports
public ModuleLayer.Controller addExports(Module source, String pn, Module target)
Updates module
source
in the layer to export a package to module target
. This method is a no-op if source
already exports the package to at least target
.- Parameters:
-
source
- The source module -
pn
- The package name -
target
- The target module - Returns:
- This controller
- Throws:
-
IllegalArgumentException
- Ifsource
is not in the module layer or the package is not in the source module - See Also:
addOpens
public ModuleLayer.Controller addOpens(Module source, String pn, Module target)
Updates module
source
in the layer to open a package to module target
. This method is a no-op if source
already opens the package to at least target
.- Parameters:
-
source
- The source module -
pn
- The package name -
target
- The target module - Returns:
- This controller
- Throws:
-
IllegalArgumentException
- Ifsource
is not in the module layer or the package is not in the source module - See Also:
© 1993, 2021, 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/17/docs/api/java.base/java/lang/ModuleLayer.Controller.html