Skip to content

Commit

Permalink
Improve GraalVM version check.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocaballero authored and fniephaus committed Dec 9, 2024
1 parent af8131c commit 355efa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class NativeImageUtils {

private static final Pattern requiredVersionPattern = Pattern.compile("^([0-9]+)(?:\\.([0-9]+)?)?(?:\\.([0-9]+)?)?$");

private static final Pattern graalvmVersionPattern = Pattern.compile("^(GraalVM|native-image) ([0-9]+)\\.([0-9]+)\\.([0-9]+).*");
private static final Pattern graalvmVersionPattern = Pattern.compile("^(GraalVM|native-image) ([0-9]+)\\.([0-9]+)\\.([0-9]+).*", Pattern.DOTALL);

private static final Pattern javaVersionPattern = Pattern.compile("^native-image ([0-9]+).*", Pattern.DOTALL);
private static final Pattern javaVersionLegacyPattern = Pattern.compile(".* \\(Java Version ([0-9]+)\\.([0-9]+)\\.([0-9]+).*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ void checkOracleGraalVMVersion() {
Assertions.assertEquals(21, NativeImageUtils.getMajorJDKVersion(oracleGraalVMForJDK21));
}

@Test
void checkOtherGraalVMVersion() {
String otherGraalVMForJDK23 = "native-image 23.0.1 2024-10-15\nJava(TM) SE Runtime Environment Foo Bar 23.0.1+11.1 (build 23.0.1+11-foo-bar-jvmci-b01)\n" +
"Java HotSpot(TM) 64-Bit Server VM Foo Bar 23.0.1+11.1 (build 23.0.1+11-foo-bar-jvmci-b01, mixed mode, sharing)";
NativeImageUtils.checkVersion("22.3.0", otherGraalVMForJDK23);
NativeImageUtils.checkVersion("23", otherGraalVMForJDK23);
NativeImageUtils.checkVersion("23.0", otherGraalVMForJDK23);
NativeImageUtils.checkVersion("23.0.1", otherGraalVMForJDK23);
Assertions.assertEquals(23, NativeImageUtils.getMajorJDKVersion(otherGraalVMForJDK23));
}

@Test
void checkGreaterVersion() {
NativeImageUtils.checkVersion("22", "GraalVM 23.2.1");
Expand Down

0 comments on commit 355efa0

Please sign in to comment.