diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/NativeImageClassLoaderOptions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/NativeImageClassLoaderOptions.java index cae1f4c4b0c7d..6f0099706161a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/NativeImageClassLoaderOptions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/NativeImageClassLoaderOptions.java @@ -48,6 +48,11 @@ public class NativeImageClassLoaderOptions { " can be ALL-UNNAMED to read all unnamed modules.")// public static final HostedOptionKey AddReads = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); + @APIOption(name = "enable-native-access", launcherOption = true, valueSeparator = {APIOption.WHITESPACE_SEPARATOR, '='})// + @Option(help = "A comma-separated list of modules that are permitted to perform restricted native operations." + + " The module name can also be ALL-UNNAMED.")// + public static final HostedOptionKey EnableNativeAccess = new HostedOptionKey<>(AccumulatingLocatableMultiOptionValue.Strings.build()); + @APIOption(name = "list-modules")// @Option(help = "List observable modules and exit.")// public static final HostedOptionKey ListModules = new HostedOptionKey<>(false); diff --git a/substratevm/src/com.oracle.svm.driver/resources/Help.txt b/substratevm/src/com.oracle.svm.driver/resources/Help.txt index d5c4e7a8cd54a..f2f24406a48de 100644 --- a/substratevm/src/com.oracle.svm.driver/resources/Help.txt +++ b/substratevm/src/com.oracle.svm.driver/resources/Help.txt @@ -31,9 +31,6 @@ where options include: -J pass directly to the JVM running the image generator --diagnostics-mode enable diagnostics output: class initialization, substitutions, etc. --enable-preview allow classes to depend on preview features of this release - --enable-native-access [,...] - modules that are permitted to perform restricted native operations. - can also be ALL-UNNAMED. --verbose enable verbose output --version print product version and exit --help print this help message diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java index cfd259c77e545..ac574b77c091d 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/DefaultOptionHandler.java @@ -47,8 +47,6 @@ class DefaultOptionHandler extends NativeImage.OptionHandler { /* Defunct legacy options that we have to accept to maintain backward compatibility */ private static final String noServerOption = "--no-server"; - private static final String nativeAccessOption = "--enable-native-access"; - DefaultOptionHandler(NativeImage nativeImage) { super(nativeImage); } @@ -130,15 +128,6 @@ public boolean consume(ArgumentQueue args) { args.poll(); nativeImage.addCustomJavaArgs("--enable-preview"); return true; - case nativeAccessOption: - args.poll(); - String modules = args.poll(); - if (modules == null) { - NativeImage.showError(nativeAccessOption + moduleSetModifierOptionErrorMessage); - } - nativeImage.addEnableNativeAccess(modules); - nativeImage.addEnableNativeAccess("org.graalvm.nativeimage.foreign"); - return true; } String singleArgClasspathPrefix = newStyleClasspathOptionName + "="; @@ -212,15 +201,6 @@ public boolean consume(ArgumentQueue args) { nativeImage.addLimitedModules(limitModulesArgs); return true; } - if (headArg.startsWith(nativeAccessOption + "=")) { - args.poll(); - String nativeAccessModules = headArg.substring(nativeAccessOption.length() + 1); - if (nativeAccessModules.isEmpty()) { - NativeImage.showError(headArg + moduleSetModifierOptionErrorMessage); - } - nativeImage.addCustomJavaArgs(headArg + ",org.graalvm.nativeimage.foreign"); - return true; - } return false; } diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index 21a01c3f096a0..d795ee1195a34 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -302,7 +302,6 @@ private static String oR(OptionKey option) { private final List excludedConfigs = new ArrayList<>(); private final LinkedHashSet addModules = new LinkedHashSet<>(); private final LinkedHashSet limitModules = new LinkedHashSet<>(); - private final LinkedHashSet enableNativeAccessModules = new LinkedHashSet<>(); private long imageBuilderPid = -1; @@ -1384,8 +1383,8 @@ private int completeImageBuild() { if (config.modulePathBuild && !finalImageClasspath.isEmpty()) { imageBuilderJavaArgs.add(DefaultOptionHandler.addModulesOption + "=ALL-DEFAULT"); } - enableNativeAccessModules.addAll(getModulesFromPath(imageBuilderModulePath).keySet()); - assert !enableNativeAccessModules.isEmpty(); + // allow native access for all modules on the image builder module path + var enableNativeAccessModules = getModulesFromPath(imageBuilderModulePath).keySet(); imageBuilderJavaArgs.add("--enable-native-access=" + String.join(",", enableNativeAccessModules)); boolean useColorfulOutput = configureBuildOutput(); @@ -2016,10 +2015,6 @@ public void addLimitedModules(String limitModulesArg) { limitModules.addAll(Arrays.asList(SubstrateUtil.split(limitModulesArg, ","))); } - public void addEnableNativeAccess(String enableNativeAccessArg) { - enableNativeAccessModules.addAll(Arrays.asList(SubstrateUtil.split(enableNativeAccessArg, ","))); - } - void addImageBuilderClasspath(Path classpath) { imageBuilderClasspath.add(canonicalize(classpath)); }