java.lang.Object
java.lang.ModuleLayer.Controller
- Enclosing class:
- ModuleLayer
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 Controllerobjects, they should never be shared with untrusted code.
- Since:
- 9
- 
Method SummaryModifier and TypeMethodDescriptionaddExports(Module source, String pn, Module target) Updates modulesourcein the layer to export a package to moduletarget.Updates modulesourcein the layer to open a package to moduletarget.Updates modulesourcein the layer to read moduletarget.enableNativeAccess(Module target) Preview.Enables native access for a module in the layer if the caller's module has native access.layer()Returns the layer that this object controls.
- 
Method Details- 
layerReturns the layer that this object controls.- Returns:
- the module layer
 
- 
addReadsUpdates modulesourcein the layer to read moduletarget. This method is a no-op ifsourcealready readstarget.- Implementation Note:
- Read edges added by this method are weak
 and do not prevent targetfrom being GC'ed whensourceis strongly reachable.
- Parameters:
- source- The source module
- target- The target module to read
- Returns:
- This controller
- Throws:
- IllegalArgumentException- If- sourceis not in the module layer
- See Also:
 
- 
addExportsUpdates modulesourcein the layer to export a package to moduletarget. This method is a no-op ifsourcealready exports the package to at leasttarget.- Parameters:
- source- The source module
- pn- The package name
- target- The target module
- Returns:
- This controller
- Throws:
- IllegalArgumentException- If- sourceis not in the module layer or the package is not in the source module
- See Also:
 
- 
addOpensUpdates modulesourcein the layer to open a package to moduletarget. This method is a no-op ifsourcealready opens the package to at leasttarget.- Parameters:
- source- The source module
- pn- The package name
- target- The target module
- Returns:
- This controller
- Throws:
- IllegalArgumentException- If- sourceis not in the module layer or the package is not in the source module
- See Also:
 
- 
enableNativeAccessenableNativeAccessis a preview API of the Java platform.Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.Enables native access for a module in the layer if the caller's module has native access.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. - Parameters:
- target- The module to update
- Returns:
- This controller
- Throws:
- IllegalArgumentException- If- targetis not in the module layer
- IllegalCallerException- If the caller is in a module that does not have native access enabled
- Since:
- 20
 
 
- 
enableNativeAccesswhen preview features are enabled.