Skip to content

Commit 4d8b719

Browse files
committed
[GR-69280] Allow use of legacy -Dgraal option prefix without warning.
PullRequest: graal/22027
2 parents a548f1b + ca789f6 commit 4d8b719

File tree

6 files changed

+26
-50
lines changed

6 files changed

+26
-50
lines changed

compiler/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This changelog summarizes newly introduced optimizations and other compiler related changes.
44

55
## GraalVM for JDK 26 (Internal Version 26.0.0)
6+
* (GR-69280): Allow use of the `graal.` prefix for Graal compiler options without issuing a warning.
67
* (GR-58163): Added support for recording and replaying JIT compilations. The `-Djdk.graal.RecordForReplay=*` option
78
serializes all compilations matching the pattern to JSON files, which contain the results of JVMCI calls. The
89
recorded compilations can be replayed with the `mx replaycomp` command. Truffle compilations are currently not

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotGraalOptionValuesTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
import java.io.PrintStream;
3535
import java.util.List;
3636

37-
import jdk.graal.compiler.test.SubprocessUtil;
3837
import org.junit.Assert;
3938
import org.junit.Test;
4039

4140
import jdk.graal.compiler.options.OptionValues;
4241
import jdk.graal.compiler.options.OptionsParser;
42+
import jdk.graal.compiler.test.SubprocessUtil;
4343

4444
public class HotSpotGraalOptionValuesTest extends HotSpotGraalCompilerTest {
4545

@@ -60,7 +60,7 @@ public void testOptionsInFile() throws IOException, InterruptedException {
6060
}
6161

6262
String expect = "The 'jdk.graal.options.file' property is no longer supported";
63-
if (!proc.output.stream().anyMatch(line -> line.contains(expect))) {
63+
if (proc.output.stream().noneMatch(line -> line.contains(expect))) {
6464
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", expect, proc.preserveArgfile()));
6565
}
6666
} finally {
@@ -75,13 +75,17 @@ public void testPrintHelp() throws IOException {
7575
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
7676
PrintStream out = new PrintStream(baos);
7777
options.printHelp(OptionsParser.getOptionsLoader(), out, GRAAL_OPTION_PROPERTY_PREFIX, all);
78-
Assert.assertNotEquals(baos.size(), 0);
78+
Assert.assertNotEquals(0, baos.size());
7979
}
8080
}
8181
}
8282

83+
/**
84+
* Ensures the legacy prefix for Graal options (i.e. {@code -Dgraal.}) is accepted without
85+
* emitting a warning.
86+
*/
8387
@Test
84-
public void testDeprecation() throws IOException, InterruptedException {
88+
public void testLegacy() throws IOException, InterruptedException {
8589
List<String> vmArgs = withoutDebuggerArguments(getVMCommandLine());
8690
vmArgs.removeIf(a -> a.startsWith("-Djdk.graal."));
8791
vmArgs.add("-Dgraal.ShowConfiguration=info");
@@ -90,11 +94,15 @@ public void testDeprecation() throws IOException, InterruptedException {
9094
vmArgs.add("--version");
9195
SubprocessUtil.Subprocess proc = SubprocessUtil.java(vmArgs);
9296

93-
String expect = "WARNING: The 'graal.' property prefix for the Graal option";
94-
long matches = proc.output.stream().filter(line -> line.contains(expect)).count();
95-
if (matches != 1) {
96-
Assert.fail(String.format("Did not find exactly 1 match for '%s' in output of command [matches: %d]:%n%s",
97-
expect, matches, proc.preserveArgfile()));
97+
if (proc.exitCode != 0) {
98+
Assert.fail(String.format("Expected non-0 exit code%n%s", proc.preserveArgfile()));
99+
}
100+
101+
for (String line : proc.output) {
102+
if (line.contains("WARNING:")) {
103+
Assert.fail(String.format("Found match for 'WARNING:' in output of command:%n%s",
104+
proc.preserveArgfile()));
105+
}
98106
}
99107
}
100108
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalOptionValues.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@
2929
import java.io.PrintStream;
3030
import java.util.Map;
3131

32-
import jdk.graal.compiler.core.common.LibGraalSupport;
33-
import jdk.graal.compiler.serviceprovider.GlobalAtomicLong;
34-
import jdk.graal.compiler.serviceprovider.GraalServices;
3532
import org.graalvm.collections.EconomicMap;
33+
34+
import jdk.graal.compiler.core.common.LibGraalSupport;
3635
import jdk.graal.compiler.options.Option;
3736
import jdk.graal.compiler.options.OptionDescriptors;
3837
import jdk.graal.compiler.options.OptionKey;
3938
import jdk.graal.compiler.options.OptionValues;
4039
import jdk.graal.compiler.options.OptionsParser;
41-
40+
import jdk.graal.compiler.serviceprovider.GraalServices;
4241
import jdk.vm.ci.common.InitTimer;
4342

4443
/**
@@ -66,11 +65,6 @@ public class HotSpotGraalOptionValues {
6665
*/
6766
public static final String LIBGRAAL_VM_OPTION_PROPERTY_PREFIX = "jdk.graal.internal.";
6867

69-
/**
70-
* Guard for issuing warning about deprecated Graal option prefix at most once.
71-
*/
72-
private static final GlobalAtomicLong LEGACY_OPTION_DEPRECATION_WARNED = new GlobalAtomicLong("LEGACY_OPTION_DEPRECATION_WARNED", 0L);
73-
7468
/**
7569
* Gets the system property assignment that would set the current value for a given option.
7670
*/
@@ -113,15 +107,9 @@ public static EconomicMap<OptionKey<?>, Object> parseOptions() {
113107
for (Map.Entry<String, String> e : savedProps.entrySet()) {
114108
String name = e.getKey();
115109
if (name.startsWith(LEGACY_GRAAL_OPTION_PROPERTY_PREFIX)) {
110+
// Convert legacy name to new name
116111
String baseName = name.substring(LEGACY_GRAAL_OPTION_PROPERTY_PREFIX.length());
117112
name = GRAAL_OPTION_PROPERTY_PREFIX + baseName;
118-
if (LEGACY_OPTION_DEPRECATION_WARNED.compareAndSet(0L, 1L)) {
119-
System.err.printf("""
120-
WARNING: The 'graal.' property prefix for the Graal option %s
121-
WARNING: (and all other Graal options) is deprecated and will be ignored
122-
WARNING: in a future release. Please use 'jdk.graal.%s' instead.%n""",
123-
baseName, baseName);
124-
}
125113
}
126114
if (name.startsWith(GRAAL_OPTION_PROPERTY_PREFIX)) {
127115
if (name.startsWith(LIBGRAAL_VM_OPTION_PROPERTY_PREFIX)) {

espresso/src/com.oracle.truffle.espresso.libjavavm/src/com/oracle/truffle/espresso/libjavavm/arghelper/Native.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
package com.oracle.truffle.espresso.libjavavm.arghelper;
2424

2525
import static com.oracle.truffle.espresso.libjavavm.Arguments.abort;
26-
import static com.oracle.truffle.espresso.libjavavm.Arguments.warn;
2726

2827
import java.util.Map.Entry;
2928
import java.util.SortedMap;
@@ -45,7 +44,6 @@ class Native {
4544
private final ArgumentsHandler handler;
4645

4746
private String argPrefix;
48-
private boolean legacyGraalOptionDeprecationWarned = false;
4947

5048
void init(boolean fromXXHandling) {
5149
argPrefix = fromXXHandling ? "-" : "--vm.";
@@ -56,13 +54,6 @@ void setNativeOption(String arg) {
5654
setGraalStyleRuntimeOption(arg.substring("Djdk.graal.".length()));
5755
} else if (arg.startsWith("Dgraal.")) {
5856
String baseName = arg.substring("Dgraal.".length());
59-
if (!legacyGraalOptionDeprecationWarned) {
60-
warn("""
61-
WARNING: The 'graal.' property prefix for the Graal option %s
62-
WARNING: (and all other Graal options) is deprecated and will be ignored
63-
WARNING: in a future release. Please use 'jdk.graal.%s' instead.""".formatted(baseName, baseName));
64-
legacyGraalOptionDeprecationWarned = true;
65-
}
6657
setGraalStyleRuntimeOption(baseName);
6758
} else if (arg.startsWith("D")) {
6859
setSystemProperty(arg.substring("D".length()));
@@ -92,7 +83,7 @@ final void printNativeHelp() {
9283
String helpMsg = descriptor.help();
9384
if (isBooleanOption(descriptor)) {
9485
Boolean val = (Boolean) descriptor.defaultValue();
95-
if (helpMsg.length() != 0) {
86+
if (!helpMsg.isEmpty()) {
9687
helpMsg += ' ';
9788
}
9889
if (val == null || !val) {

substratevm/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This changelog summarizes major changes to GraalVM Native Image.
44

5+
## GraalVM for JDK 26 (Internal Version 26.0.0)
6+
* (GR-69280): Allow use of the `graal.` prefix for options without issuing a warning.
7+
58
## GraalVM for JDK 25
69
* (GR-52276) (GR-61959) Add support for Arena.ofShared().
710
* (GR-58668) Enabled [Whole-Program Sparse Conditional Constant Propagation (WP-SCCP)](https://github.com/oracle/graal/pull/9821) by default, improving the precision of points-to analysis in Native Image. This optimization enhances static analysis accuracy and scalability, potentially reducing the size of the final native binary.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionParser.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Arrays;
2828
import java.util.EnumSet;
2929
import java.util.Optional;
30-
import java.util.concurrent.atomic.AtomicBoolean;
3130
import java.util.function.Predicate;
3231

3332
import org.graalvm.collections.EconomicMap;
@@ -76,11 +75,6 @@ public final class RuntimeOptionParser implements DuplicableImageSingleton {
7675
*/
7776
private static final String LEGACY_GRAAL_OPTION_PREFIX = "-Dgraal.";
7877

79-
/**
80-
* Guard for issuing warning about deprecated Graal option prefix at most once.
81-
*/
82-
private static final AtomicBoolean LEGACY_OPTION_DEPRECATION_WARNED = new AtomicBoolean();
83-
8478
/**
8579
* The prefix for XOptions available in an application based on Substrate VM.
8680
*/
@@ -152,15 +146,6 @@ public String[] parse(String[] args, String normalOptionPrefix, String graalOpti
152146
} else if (graalOptionPrefix != null && arg.startsWith(graalOptionPrefix)) {
153147
parseOptionAtRuntime(arg, graalOptionPrefix, BooleanOptionFormat.NAME_VALUE, values, ignoreUnrecognized);
154148
} else if (legacyGraalOptionPrefix != null && arg.startsWith(legacyGraalOptionPrefix)) {
155-
String baseName = arg.substring(legacyGraalOptionPrefix.length());
156-
if (LEGACY_OPTION_DEPRECATION_WARNED.compareAndExchange(false, true)) {
157-
Log log = Log.log();
158-
// Checkstyle: Allow raw info or warning printing - begin
159-
log.string("WARNING: The 'graal.' property prefix for the Graal option ").string(baseName).newline();
160-
log.string("WARNING: (and all other Graal options) is deprecated and will be ignored").newline();
161-
log.string("WARNING: in a future release. Please use 'jdk.graal.").string(baseName).string("' instead.").newline();
162-
// Checkstyle: Allow raw info or warning printing - end
163-
}
164149
parseOptionAtRuntime(arg, legacyGraalOptionPrefix, BooleanOptionFormat.NAME_VALUE, values, ignoreUnrecognized);
165150
} else if (xOptionPrefix != null && arg.startsWith(xOptionPrefix) && XOptions.parse(arg.substring(xOptionPrefix.length()), values)) {
166151
// option value was already parsed and added to the map

0 commit comments

Comments
 (0)