Skip to content

[GR-54646] Forbid "graal." prefix for Graal options #11481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ public void testPrintHelp() throws IOException {
}

@Test
public void testDeprecation() throws IOException, InterruptedException {
public void testLegacyOptionError() throws IOException, InterruptedException {
List<String> 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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -114,14 +110,8 @@ public static EconomicMap<OptionKey<?>, 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Native {
private final ArgumentsHandler handler;

private String argPrefix;
private boolean legacyGraalOptionDeprecationWarned = false;

void init(boolean fromXXHandling) {
argPrefix = fromXXHandling ? "-" : "--vm.";
Expand All @@ -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:")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 {
Expand Down
34 changes: 15 additions & 19 deletions vm/mx.vm/mx_vm_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
Loading