289 * @return This controller
290 *
291 * @throws IllegalArgumentException
292 * If {@code source} is not in the module layer or the package
293 * is not in the source module
294 *
295 * @see Module#addOpens
296 */
297 public Controller addOpens(Module source, String pn, Module target) {
298 ensureInLayer(source);
299 source.implAddOpens(pn, target);
300 return this;
301 }
302
303 /**
304 * Enables native access for a module in the layer if the caller's module
305 * has native access.
306 *
307 * <p> This method is <a href="foreign/package-summary.html#restricted"><em>restricted</em></a>.
308 * Restricted methods are unsafe, and, if used incorrectly, their use might crash
309 * the JVM or, worse, silently result in memory corruption. Thus, clients should refrain
310 * from depending on restricted methods, and use safe and supported functionalities,
311 * where possible.
312 *
313 * @param target
314 * The module to update
315 *
316 * @return This controller
317 *
318 * @throws IllegalArgumentException
319 * If {@code target} is not in the module layer
320 *
321 * @throws IllegalCallerException
322 * If the caller is in a module that does not have native access enabled
323 *
324 * @since 20
325 */
326 @PreviewFeature(feature=PreviewFeature.Feature.FOREIGN)
327 @CallerSensitive
328 public Controller enableNativeAccess(Module target) {
329 ensureInLayer(target);
330 Reflection.ensureNativeAccess(Reflection.getCallerClass(), Module.class,
331 "enableNativeAccess");
332 target.implAddEnableNativeAccess();
333 return this;
334 }
335 }
336
337
338 /**
339 * Creates a new module layer, with this layer as its parent, by defining the
340 * modules in the given {@code Configuration} to the Java virtual machine.
341 * This method creates one class loader and defines all modules to that
342 * class loader. The {@link ClassLoader#getParent() parent} of each class
343 * loader is the given parent class loader. This method works exactly as
344 * specified by the static {@link
345 * #defineModulesWithOneLoader(Configuration,List,ClassLoader)
346 * defineModulesWithOneLoader} method when invoked with this layer as the
|
289 * @return This controller
290 *
291 * @throws IllegalArgumentException
292 * If {@code source} is not in the module layer or the package
293 * is not in the source module
294 *
295 * @see Module#addOpens
296 */
297 public Controller addOpens(Module source, String pn, Module target) {
298 ensureInLayer(source);
299 source.implAddOpens(pn, target);
300 return this;
301 }
302
303 /**
304 * Enables native access for a module in the layer if the caller's module
305 * has native access.
306 *
307 * <p> This method is <a href="foreign/package-summary.html#restricted"><em>restricted</em></a>.
308 * Restricted methods are unsafe, and, if used incorrectly, their use might crash
309 * the JVM or, worse, silently result in memory corruption.
310 *
311 * @param target
312 * The module to update
313 *
314 * @return This controller
315 *
316 * @throws IllegalArgumentException
317 * If {@code target} is not in the module layer
318 *
319 * @throws IllegalCallerException
320 * If the caller is in a module that does not have native access enabled
321 *
322 * @since 22
323 */
324 @CallerSensitive
325 public Controller enableNativeAccess(Module target) {
326 ensureInLayer(target);
327 Reflection.ensureNativeAccess(Reflection.getCallerClass(), Module.class,
328 "enableNativeAccess");
329 target.implAddEnableNativeAccess();
330 return this;
331 }
332 }
333
334
335 /**
336 * Creates a new module layer, with this layer as its parent, by defining the
337 * modules in the given {@code Configuration} to the Java virtual machine.
338 * This method creates one class loader and defines all modules to that
339 * class loader. The {@link ClassLoader#getParent() parent} of each class
340 * loader is the given parent class loader. This method works exactly as
341 * specified by the static {@link
342 * #defineModulesWithOneLoader(Configuration,List,ClassLoader)
343 * defineModulesWithOneLoader} method when invoked with this layer as the
|