From cbeae45a1a780c9d360cfe2a15c3bac2b1eb24de Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Wed, 25 Jun 2025 19:01:47 +0200 Subject: [PATCH] make use of the "graal." prefix for Graal options an error --- compiler/CHANGELOG.md | 9 +++++ .../ea/ReadEliminationCodeEmissionTest.java | 2 +- .../test/HotSpotGraalOptionValuesTest.java | 6 ++-- .../hotspot/HotSpotGraalOptionValues.java | 18 +++------- .../espresso/libjavavm/arghelper/Native.java | 10 +----- .../svm/core/option/RuntimeOptionParser.java | 16 ++------- vm/mx.vm/mx_vm_gate.py | 34 ++++++++----------- 7 files changed, 35 insertions(+), 60 deletions(-) diff --git a/compiler/CHANGELOG.md b/compiler/CHANGELOG.md index 32fb116f6396..c3062935d388 100644 --- a/compiler/CHANGELOG.md +++ b/compiler/CHANGELOG.md @@ -2,6 +2,15 @@ This changelog summarizes newly introduced optimizations and other compiler related changes. +## GraalVM for JDK 26 (Internal Version 26.0.0) +* (GR-54646): Using the `graal.` prefix for Graal options is no longer supported and causes an error at startup. + For example: + ``` + > java -Dgraal.ShowConfiguration=info Hello.java + Error parsing Graal options: The 'graal.' prefix for ShowConfiguration is unsupported - use 'jdk.graal.ShowConfiguration' instead. + Error: A fatal exception has occurred. Program will exit. + ``` + ## GraalVM for JDK 25 (Internal Version 25.0.0) * (GR-60088): This PR adds the `org.graalvm.nativeimage.libgraal` SDK module. With this module, all logic for building libgraal has been moved into the compiler suite in a new `jdk.graal.compiler.libgraal` module diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/ReadEliminationCodeEmissionTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/ReadEliminationCodeEmissionTest.java index a24cb2969b85..467c292829e8 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/ReadEliminationCodeEmissionTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/ReadEliminationCodeEmissionTest.java @@ -117,7 +117,7 @@ public void runTest(String baseName, Object... args) { "-XX:+PreserveFramePointer", "-Xbatch", "-XX:LogFile=" + logName, - "-Dgraal.Dump=:5"}; + "-Djdk.graal.Dump=:5"}; } try { subprocess = launchSubprocess(run, vmArgs); diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotGraalOptionValuesTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotGraalOptionValuesTest.java index 3d848fb32a69..85d8881fa108 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotGraalOptionValuesTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotGraalOptionValuesTest.java @@ -81,16 +81,16 @@ public void testPrintHelp() throws IOException { } @Test - public void testDeprecation() throws IOException, InterruptedException { + public void testLegacyOptionError() throws IOException, InterruptedException { List vmArgs = withoutDebuggerArguments(getVMCommandLine()); vmArgs.removeIf(a -> a.startsWith("-Djdk.graal.")); vmArgs.add("-Dgraal.ShowConfiguration=info"); - vmArgs.add("-Dgraal.PrintCompilation=true"); vmArgs.add("-XX:+EagerJVMCI"); vmArgs.add("--version"); SubprocessUtil.Subprocess proc = SubprocessUtil.java(vmArgs); - String expect = "WARNING: The 'graal.' property prefix for the Graal option"; + Assert.assertNotEquals(proc.preserveArgfile().toString(), 0, proc.exitCode); + String expect = "Error parsing Graal options: The 'graal.' prefix for ShowConfiguration is unsupported - use 'jdk.graal.ShowConfiguration' instead."; long matches = proc.output.stream().filter(line -> line.contains(expect)).count(); if (matches != 1) { Assert.fail(String.format("Did not find exactly 1 match for '%s' in output of command [matches: %d]:%n%s", diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java index 437c4a9c6b60..21d7fd9e984d 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java @@ -59,18 +59,14 @@ public class HotSpotGraalOptionValues { * {@code GRAAL_OPTION_PROPERTY_PREFIX + "MyOption"}. */ public static final String GRAAL_OPTION_PROPERTY_PREFIX = "jdk.graal."; - public static final String LEGACY_GRAAL_OPTION_PROPERTY_PREFIX = "graal."; + + private static final String LEGACY_GRAAL_OPTION_PROPERTY_PREFIX = "graal."; /** * Prefix for system properties that correspond to libgraal Native Image options. */ public static final String LIBGRAAL_VM_OPTION_PROPERTY_PREFIX = "jdk.graal.internal."; - /** - * Guard for issuing warning about deprecated Graal option prefix at most once. - */ - private static final GlobalAtomicLong LEGACY_OPTION_DEPRECATION_WARNED = new GlobalAtomicLong("LEGACY_OPTION_DEPRECATION_WARNED", 0L); - /** * Gets the system property assignment that would set the current value for a given option. */ @@ -114,14 +110,8 @@ public static EconomicMap, Object> parseOptions() { String name = e.getKey(); if (name.startsWith(LEGACY_GRAAL_OPTION_PROPERTY_PREFIX)) { String baseName = name.substring(LEGACY_GRAAL_OPTION_PROPERTY_PREFIX.length()); - name = GRAAL_OPTION_PROPERTY_PREFIX + baseName; - if (LEGACY_OPTION_DEPRECATION_WARNED.compareAndSet(0L, 1L)) { - System.err.printf(""" - WARNING: The 'graal.' property prefix for the Graal option %s - WARNING: (and all other Graal options) is deprecated and will be ignored - WARNING: in a future release. Please use 'jdk.graal.%s' instead.%n""", - baseName, baseName); - } + String msg = String.format("The 'graal.' prefix for %s is unsupported - use 'jdk.graal.%s' instead.", baseName, baseName); + throw new IllegalArgumentException(msg); } if (name.startsWith(GRAAL_OPTION_PROPERTY_PREFIX)) { if (name.startsWith(LIBGRAAL_VM_OPTION_PROPERTY_PREFIX)) { diff --git a/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java b/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java index 94348b6dddcc..763afb2d1581 100644 --- a/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java +++ b/espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java @@ -45,7 +45,6 @@ class Native { private final ArgumentsHandler handler; private String argPrefix; - private boolean legacyGraalOptionDeprecationWarned = false; void init(boolean fromXXHandling) { argPrefix = fromXXHandling ? "-" : "--vm."; @@ -56,14 +55,7 @@ void setNativeOption(String arg) { setGraalStyleRuntimeOption(arg.substring("Djdk.graal.".length())); } else if (arg.startsWith("Dgraal.")) { String baseName = arg.substring("Dgraal.".length()); - if (!legacyGraalOptionDeprecationWarned) { - warn(""" - WARNING: The 'graal.' property prefix for the Graal option %s - WARNING: (and all other Graal options) is deprecated and will be ignored - WARNING: in a future release. Please use 'jdk.graal.%s' instead.""".formatted(baseName, baseName)); - legacyGraalOptionDeprecationWarned = true; - } - setGraalStyleRuntimeOption(baseName); + throw abort("The 'graal.' prefix for " + baseName + " is unsupported - use 'jdk.graal." + baseName + "' instead."); } else if (arg.startsWith("D")) { setSystemProperty(arg.substring("D".length())); } else if (arg.startsWith("XX:")) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionParser.java index df99572d13f0..c7f5dd2c67cd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionParser.java @@ -76,11 +76,6 @@ public final class RuntimeOptionParser implements DuplicableImageSingleton { */ private static final String LEGACY_GRAAL_OPTION_PREFIX = "-Dgraal."; - /** - * Guard for issuing warning about deprecated Graal option prefix at most once. - */ - private static final AtomicBoolean LEGACY_OPTION_DEPRECATION_WARNED = new AtomicBoolean(); - /** * The prefix for XOptions available in an application based on Substrate VM. */ @@ -153,15 +148,8 @@ public String[] parse(String[] args, String normalOptionPrefix, String graalOpti parseOptionAtRuntime(arg, graalOptionPrefix, BooleanOptionFormat.NAME_VALUE, values, ignoreUnrecognized); } else if (legacyGraalOptionPrefix != null && arg.startsWith(legacyGraalOptionPrefix)) { String baseName = arg.substring(legacyGraalOptionPrefix.length()); - if (LEGACY_OPTION_DEPRECATION_WARNED.compareAndExchange(false, true)) { - Log log = Log.log(); - // Checkstyle: Allow raw info or warning printing - begin - log.string("WARNING: The 'graal.' property prefix for the Graal option ").string(baseName).newline(); - log.string("WARNING: (and all other Graal options) is deprecated and will be ignored").newline(); - log.string("WARNING: in a future release. Please use 'jdk.graal.").string(baseName).string("' instead.").newline(); - // Checkstyle: Allow raw info or warning printing - end - } - parseOptionAtRuntime(arg, legacyGraalOptionPrefix, BooleanOptionFormat.NAME_VALUE, values, ignoreUnrecognized); + String msg = String.format("The 'graal.' prefix for %s is unsupported - use 'jdk.graal.%s' instead.", baseName, baseName); + throw new IllegalArgumentException(msg); } else if (xOptionPrefix != null && arg.startsWith(xOptionPrefix) && XOptions.parse(arg.substring(xOptionPrefix.length()), values)) { // option value was already parsed and added to the map } else { diff --git a/vm/mx.vm/mx_vm_gate.py b/vm/mx.vm/mx_vm_gate.py index 4cbb22941059..47ea5ae13016 100644 --- a/vm/mx.vm/mx_vm_gate.py +++ b/vm/mx.vm/mx_vm_gate.py @@ -186,28 +186,24 @@ def extra_check(compiler_log): table = f' Count Stub{nl} ' + f'{nl} '.join((f'{count:<8d} {stub}') for stub, count in stub_compilations.items()) mx.abort(f'Following stubs were compiled more than once according to compiler log:{nl}{table}') - # Test that legacy `-D.graal` options work. - show_config_args = ('-Djdk.graal.ShowConfiguration=verbose', '-Dgraal.ShowConfiguration=verbose') + args = check_stub_sharing + ['-Djdk.graal.ShowConfiguration=verbose'] + _get_CountUppercase_vmargs() - for show_config_arg in show_config_args: - args = check_stub_sharing + [show_config_arg] + _get_CountUppercase_vmargs() - - # Verify execution via raw java launcher in `mx graalvm-home`. - for jre_name, jre, jre_args in jres: - try: - cmd = [join(jre, 'bin', 'java')] + jre_args + extra_vm_arguments + args - mx.log(f'{jre_name}: {" ".join(cmd)}') - mx.run(cmd) - finally: - _check_compiler_log(compiler_log_file, expect, extra_check=extra_check) - - # Verify execution via `mx vm`. - import mx_compiler + # Verify execution via raw java launcher in `mx graalvm-home`. + for jre_name, jre, jre_args in jres: try: - mx.log(f'mx.run_vm: args={extra_vm_arguments + args}') - mx_compiler.run_vm(extra_vm_arguments + args) + cmd = [join(jre, 'bin', 'java')] + jre_args + extra_vm_arguments + args + mx.log(f'{jre_name}: {" ".join(cmd)}') + mx.run(cmd) finally: - _check_compiler_log(compiler_log_file, expect) + _check_compiler_log(compiler_log_file, expect, extra_check=extra_check) + + # Verify execution via `mx vm`. + import mx_compiler + try: + mx.log(f'mx.run_vm: args={extra_vm_arguments + args}') + mx_compiler.run_vm(extra_vm_arguments + args) + finally: + _check_compiler_log(compiler_log_file, expect) def _test_libgraal_fatal_error_handling(extra_vm_arguments): """