Skip to content

Commit fffeb29

Browse files
committed
factored out min Java release requirement in JVMCIVersionCheck
1 parent a951823 commit fffeb29

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/JVMCIVersionCheck.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@
4343
*/
4444
public final class JVMCIVersionCheck {
4545

46+
/**
47+
* Minimum JVMCI version supported by Graal.
48+
*/
4649
private static final Version JVMCI_MIN_VERSION = new Version(22, 3, 11);
4750

51+
/**
52+
* Minimum Java release supported by Graal.
53+
*/
54+
private static final int JAVA_MIN_RELEASE = 17;
55+
4856
public static class Version {
4957
private final int major;
5058
private final int minor;
@@ -123,10 +131,10 @@ private void failVersionCheck(boolean exit, String reason, Object... args) {
123131
errorMessage.format("this error or to \"warn\" to emit a warning and continue execution.%n");
124132
errorMessage.format("Currently used Java home directory is %s.%n", javaHome);
125133
errorMessage.format("Currently used VM configuration is: %s%n", vmName);
126-
if (javaSpecVersion.compareTo("11") == 0 && vmVersion.contains("-jvmci-")) {
134+
if (vmVersion.contains("-jvmci-")) {
127135
errorMessage.format("Download the latest Labs OpenJDK from " + OPEN_LABSJDK_RELEASE_URL_PATTERN);
128136
} else {
129-
errorMessage.format("Download JDK 17 or later.");
137+
errorMessage.format("Download JDK %s or later.", JAVA_MIN_RELEASE);
130138
}
131139
String value = System.getenv("JVMCI_VERSION_CHECK");
132140
if ("warn".equals(value)) {
@@ -168,8 +176,8 @@ public static void check(Map<String, String> props,
168176
}
169177

170178
private void run(boolean exitOnFailure, Version minVersion, boolean quiet) {
171-
if (javaSpecVersion.compareTo("17") < 0) {
172-
failVersionCheck(exitOnFailure, "Graal requires JDK 17 or later.%n");
179+
if (javaSpecVersion.compareTo(Integer.toString(JAVA_MIN_RELEASE)) < 0) {
180+
failVersionCheck(exitOnFailure, "Graal requires JDK " + JAVA_MIN_RELEASE + " or later.%n");
173181
} else {
174182
if (vmVersion.contains("SNAPSHOT")) {
175183
return;
@@ -193,7 +201,7 @@ private void run(boolean exitOnFailure, Version minVersion, boolean quiet) {
193201
failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
194202
"Cannot read JVMCI version from java.vm.version property: %s.%n", vmVersion);
195203
} else {
196-
// Graal is compatible with all JDK versions as of 17 GA.
204+
// Graal is compatible with all JDK versions as of JAVA_MIN_RELEASE
197205
}
198206
}
199207
}

0 commit comments

Comments
 (0)