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 ;
@@ -281,7 +282,7 @@ static void check(Map<String, String> props, boolean exitOnFailure, PrintFormat
281
282
*/
282
283
public static void check (Map <String , String > props , boolean exitOnFailure , PrintFormat format , Map <String , Map <String , Version >> jvmciMinVersions ) {
283
284
JVMCIVersionCheck checker = newJVMCIVersionCheck (props );
284
- String reason = checker .run (getMinVersion (props , jvmciMinVersions ), format );
285
+ String reason = checker .run (getMinVersion (props , jvmciMinVersions ), format , jvmciMinVersions );
285
286
if (reason != null ) {
286
287
Formatter errorMessage = new Formatter ().format ("%s%n" , reason );
287
288
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) {
340
341
*/
341
342
public static String check (Map <String , String > props ) {
342
343
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 );
344
345
if (reason != null ) {
345
346
Formatter errorMessage = new Formatter ().format ("%s%n" , reason );
346
347
checker .appendJVMInfo (errorMessage );
@@ -354,7 +355,7 @@ public static String check(Map<String, String> props) {
354
355
*
355
356
* @return an error message if the version check fails, or {@code null} if no error is detected
356
357
*/
357
- private String run (Version minVersion , PrintFormat format ) {
358
+ private String run (Version minVersion , PrintFormat format , Map < String , Map < String , Version >> jvmciMinVersions ) {
358
359
if (javaSpecVersion .compareTo (Integer .toString (JAVA_MIN_RELEASE )) < 0 ) {
359
360
return "Graal requires JDK " + JAVA_MIN_RELEASE + " or later." ;
360
361
} else {
@@ -374,6 +375,14 @@ private String run(Version minVersion, PrintFormat format) {
374
375
}
375
376
// A "labsjdk" or a known OpenJDK
376
377
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
+ }
377
386
// No minimum JVMCI version specified for JDK version
378
387
return null ;
379
388
}
0 commit comments