< prev index next > src/java.base/share/classes/java/lang/ModuleLayer.java
Print this page
* Enables native access for a module in the layer if the caller's module
* has native access.
*
* <p> This method is <a href="foreign/package-summary.html#restricted"><em>restricted</em></a>.
* 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.
*
* @param target
* The module to update
*
* @return This controller
* Enables native access for a module in the layer if the caller's module
* has native access.
*
* <p> This method is <a href="foreign/package-summary.html#restricted"><em>restricted</em></a>.
* Restricted methods are unsafe, and, if used incorrectly, their use might crash
! * the JVM or, worse, silently result in memory corruption.
*
* @param target
* The module to update
*
* @return This controller
* If {@code target} is not in the module layer
*
* @throws IllegalCallerException
* If the caller is in a module that does not have native access enabled
*
! * @since 20
*/
- @PreviewFeature(feature=PreviewFeature.Feature.FOREIGN)
@CallerSensitive
@Restricted
public Controller enableNativeAccess(Module target) {
ensureInLayer(target);
Reflection.ensureNativeAccess(Reflection.getCallerClass(), Module.class,
* If {@code target} is not in the module layer
*
* @throws IllegalCallerException
* If the caller is in a module that does not have native access enabled
*
! * @since 22
*/
@CallerSensitive
@Restricted
public Controller enableNativeAccess(Module target) {
ensureInLayer(target);
Reflection.ensureNativeAccess(Reflection.getCallerClass(), Module.class,
< prev index next >