Skip to content

Commit 6d8cc3c

Browse files
committed
compiler: JVMCIVersionCheck should complain if executed with outdated JDK major version
1 parent d6ddf70 commit 6d8cc3c

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;
@@ -270,7 +271,7 @@ static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat
270271
*/
271272
public static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat format, Map<String, Map<String, Version>> jvmciMinVersions) {
272273
JVMCIVersionCheck checker = newJVMCIVersionCheck(props);
273-
String reason = checker.run(getMinVersion(props, jvmciMinVersions), format);
274+
String reason = checker.run(getMinVersion(props, jvmciMinVersions), format, jvmciMinVersions);
274275
if (reason != null) {
275276
Formatter errorMessage = new Formatter().format("%s%n", reason);
276277
errorMessage.format("Set the JVMCI_VERSION_CHECK environment variable to \"ignore\" to suppress ");
@@ -329,7 +330,7 @@ private static void failVersionCheck(boolean exit, String errorMessage) {
329330
*/
330331
public static String check(Map<String, String> props) {
331332
JVMCIVersionCheck checker = newJVMCIVersionCheck(props);
332-
String reason = checker.run(getMinVersion(props, JVMCI_MIN_VERSIONS), null);
333+
String reason = checker.run(getMinVersion(props, JVMCI_MIN_VERSIONS), null, JVMCI_MIN_VERSIONS);
333334
if (reason != null) {
334335
Formatter errorMessage = new Formatter().format("%s%n", reason);
335336
checker.appendJVMInfo(errorMessage);
@@ -343,7 +344,7 @@ public static String check(Map<String, String> props) {
343344
*
344345
* @return an error message if the version check fails, or {@code null} if no error is detected
345346
*/
346-
private String run(Version minVersion, PrintFormat format) {
347+
private String run(Version minVersion, PrintFormat format, Map<String, Map<String, Version>> jvmciMinVersions) {
347348
if (javaSpecVersion.compareTo(Integer.toString(JAVA_MIN_RELEASE)) < 0) {
348349
return "Graal requires JDK " + JAVA_MIN_RELEASE + " or later.";
349350
} else {
@@ -363,6 +364,14 @@ private String run(Version minVersion, PrintFormat format) {
363364
}
364365
// A "labsjdk" or a known OpenJDK
365366
if (minVersion == null) {
367+
OptionalInt max = jvmciMinVersions.keySet().stream().mapToInt(Integer::parseInt).max();
368+
if (max.isPresent()) {
369+
int maxVersion = max.getAsInt();
370+
int specVersion = Integer.parseInt(javaSpecVersion);
371+
if (specVersion < maxVersion) {
372+
return String.format("The VM does not support JDK %s. Please update to JDK %s.", specVersion, maxVersion);
373+
}
374+
}
366375
// No minimum JVMCI version specified for JDK version
367376
return null;
368377
}

0 commit comments

Comments
 (0)