8346778: Enable native access should work with the source launcher

Reviewed-by: alanb
This commit is contained in:
Christian Stein 2025-01-14 10:34:51 +00:00
parent cbb2b847e4
commit fec769b0a8
6 changed files with 82 additions and 15 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -834,9 +834,15 @@ public final class ModuleBootstrap {
/**
* Grants native access to modules selected using the --enable-native-access
* command line option, and also to JDK modules that need the access.
* <p>
* In case of being in "source" launcher mode, warnings about unknown modules are
* deferred to the source launcher logic in the jdk.compiler module, as those
* modules might be not compiled, yet.
*/
private static void addEnableNativeAccess(ModuleLayer layer) {
addEnableNativeAccess(layer, USER_NATIVE_ACCESS_MODULES, true);
String launcherMode = getAndRemoveProperty("sun.java.launcher.mode");
boolean shouldWarn = !"source".equals(launcherMode);
addEnableNativeAccess(layer, USER_NATIVE_ACCESS_MODULES, shouldWarn);
addEnableNativeAccess(layer, JDK_NATIVE_ACCESS_MODULES, false);
}