28
28
import java .util .HashMap ;
29
29
import java .util .Map ;
30
30
import java .util .Objects ;
31
+ import java .util .OptionalInt ;
31
32
import java .util .Properties ;
32
33
import java .util .regex .Matcher ;
33
34
import java .util .regex .Pattern ;
@@ -270,7 +271,7 @@ static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat
270
271
*/
271
272
public static void check (Map <String , String > props , boolean exitOnFailure , PrintFormat format , Map <String , Map <String , Version >> jvmciMinVersions ) {
272
273
JVMCIVersionCheck checker = newJVMCIVersionCheck (props );
273
- String reason = checker .run (getMinVersion (props , jvmciMinVersions ), format );
274
+ String reason = checker .run (getMinVersion (props , jvmciMinVersions ), format , jvmciMinVersions );
274
275
if (reason != null ) {
275
276
Formatter errorMessage = new Formatter ().format ("%s%n" , reason );
276
277
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) {
329
330
*/
330
331
public static String check (Map <String , String > props ) {
331
332
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 );
333
334
if (reason != null ) {
334
335
Formatter errorMessage = new Formatter ().format ("%s%n" , reason );
335
336
checker .appendJVMInfo (errorMessage );
@@ -343,7 +344,7 @@ public static String check(Map<String, String> props) {
343
344
*
344
345
* @return an error message if the version check fails, or {@code null} if no error is detected
345
346
*/
346
- private String run (Version minVersion , PrintFormat format ) {
347
+ private String run (Version minVersion , PrintFormat format , Map < String , Map < String , Version >> jvmciMinVersions ) {
347
348
if (javaSpecVersion .compareTo (Integer .toString (JAVA_MIN_RELEASE )) < 0 ) {
348
349
return "Graal requires JDK " + JAVA_MIN_RELEASE + " or later." ;
349
350
} else {
@@ -363,6 +364,14 @@ private String run(Version minVersion, PrintFormat format) {
363
364
}
364
365
// A "labsjdk" or a known OpenJDK
365
366
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
+ }
366
375
// No minimum JVMCI version specified for JDK version
367
376
return null ;
368
377
}
0 commit comments