Skip to content

Commit c799451

Browse files
committed
[GR-60625] JVMCIVersionCheck should complain if executed with outdated JDK major version
PullRequest: graal/19651
2 parents 8ef2508 + 6d8cc3c commit c799451

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.HashMap;
2929
import java.util.Map;
3030
import java.util.Objects;
31+
import java.util.OptionalInt;
3132
import java.util.Properties;
3233
import java.util.regex.Matcher;
3334
import java.util.regex.Pattern;
@@ -281,7 +282,7 @@ static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat
281282
*/
282283
public static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat format, Map<String, Map<String, Version>> jvmciMinVersions) {
283284
JVMCIVersionCheck checker = newJVMCIVersionCheck(props);
284-
String reason = checker.run(getMinVersion(props, jvmciMinVersions), format);
285+
String reason = checker.run(getMinVersion(props, jvmciMinVersions), format, jvmciMinVersions);
285286
if (reason != null) {
286287
Formatter errorMessage = new Formatter().format("%s%n", reason);
287288
errorMessage.format("Set the JVMCI_VERSION_CHECK environment variable to \"ignore\" to suppress ");
@@ -340,7 +341,7 @@ private static void failVersionCheck(boolean exit, String errorMessage) {
340341
*/
341342
public static String check(Map<String, String> props) {
342343
JVMCIVersionCheck checker = newJVMCIVersionCheck(props);
343-
String reason = checker.run(getMinVersion(props, JVMCI_MIN_VERSIONS), null);
344+
String reason = checker.run(getMinVersion(props, JVMCI_MIN_VERSIONS), null, JVMCI_MIN_VERSIONS);
344345
if (reason != null) {
345346
Formatter errorMessage = new Formatter().format("%s%n", reason);
346347
checker.appendJVMInfo(errorMessage);
@@ -354,7 +355,7 @@ public static String check(Map<String, String> props) {
354355
*
355356
* @return an error message if the version check fails, or {@code null} if no error is detected
356357
*/
357-
private String run(Version minVersion, PrintFormat format) {
358+
private String run(Version minVersion, PrintFormat format, Map<String, Map<String, Version>> jvmciMinVersions) {
358359
if (javaSpecVersion.compareTo(Integer.toString(JAVA_MIN_RELEASE)) < 0) {
359360
return "Graal requires JDK " + JAVA_MIN_RELEASE + " or later.";
360361
} else {
@@ -374,6 +375,14 @@ private String run(Version minVersion, PrintFormat format) {
374375
}
375376
// A "labsjdk" or a known OpenJDK
376377
if (minVersion == null) {
378+
OptionalInt max = jvmciMinVersions.keySet().stream().mapToInt(Integer::parseInt).max();
379+
if (max.isPresent()) {
380+
int maxVersion = max.getAsInt();
381+
int specVersion = Integer.parseInt(javaSpecVersion);
382+
if (specVersion < maxVersion) {
383+
return String.format("The VM does not support JDK %s. Please update to JDK %s.", specVersion, maxVersion);
384+
}
385+
}
377386
// No minimum JVMCI version specified for JDK version
378387
return null;
379388
}

0 commit comments

Comments
 (0)