ModuleLayerpublic static final class ModuleLayer.Controller extends Object
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. 
Controller objects, they should never be shared with untrusted code.| Modifier and Type | Method | Description | 
|---|---|---|
| ModuleLayer.Controller | addExports | Updates module  sourcein the layer to export a package to moduletarget. | 
| ModuleLayer.Controller | addOpens | Updates module  sourcein the layer to open a package to moduletarget. | 
| ModuleLayer.Controller | addReads | Updates module  sourcein the layer to read moduletarget. | 
| ModuleLayer.Controller | enableNativeAccess | Preview. Enables native access for a module in the layer if the caller's module has native access. | 
| ModuleLayer | layer() | Returns the layer that this object controls. | 
public ModuleLayer layer()
public ModuleLayer.Controller addReads(Module source, Module target)
source in the layer to read module target. This method is a no-op if source already reads target.target from being GC'ed when source is strongly reachable.source - The source moduletarget - The target module to readIllegalArgumentException - If source is not in the module layerpublic ModuleLayer.Controller addExports(Module source, String pn, Module target)
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.source - The source modulepn - The package nametarget - The target moduleIllegalArgumentException - If source is not in the module layer or the package is not in the source modulepublic ModuleLayer.Controller addOpens(Module source, String pn, Module target)
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.source - The source modulepn - The package nametarget - The target moduleIllegalArgumentException - If source is not in the module layer or the package is not in the source modulepublic ModuleLayer.Controller enableNativeAccess(Module target)
enableNativeAccess is a preview API of the Java platform. This method is restricted. Restricted methods are unsafe, and, if used incorrectly, their use might crash the JVM or, worse, silently result in memory corruption. Thus, clients should refrain from depending on restricted methods, and use safe and supported functionalities, where possible.
target - The module to updateIllegalArgumentException - If target is not in the module layerIllegalCallerException - If the caller is in a module that does not have native access enabled
    © 1993, 2023, 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/21/docs/api/java.base/java/lang/ModuleLayer.Controller.html
  
enableNativeAccesswhen preview features are enabled.