Skip to content

Commit

Permalink
Merge pull request #37651 from brunocaballero/new-graalvm-checker-run…
Browse files Browse the repository at this point in the history
…time-vm-name

Fix GraalVM version checker in order to accept other implementations
  • Loading branch information
zakkak authored Dec 11, 2023
2 parents 9d9cb79 + aefe8a3 commit 0b7462d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ static final class VersionParseHelper {

private static final String VENDOR_VERS = "(?<VENDOR>.*)";
private static final String JDK_DEBUG = "[^\\)]*"; // zero or more of >anything not a ')'<
private static final String RUNTIME_NAME = "(?<RUNTIME>(?:OpenJDK|GraalVM) Runtime Environment) ";
private static final String RUNTIME_NAME = "(?<RUNTIME>(?:.*) Runtime Environment) ";
private static final String BUILD_INFO = "(?<BUILDINFO>.*)";
private static final String VM_NAME = "(?<VM>(?:OpenJDK 64-Bit Server|Substrate) VM) ";
private static final String VM_NAME = "(?<VM>(?:.*) VM) ";

private static final String FIRST_LINE_PATTERN = "native-image " + VSTR_FORMAT + " .*$";
private static final String SECOND_LINE_PATTERN = RUNTIME_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public void testGraalVMVersionDetected() {
+ "GraalVM Runtime Environment GraalVM CE (build 20+34-jvmci-23.0-b10)\n"
+ "Substrate VM GraalVM CE (build 20+34, serial gc)").split("\\n"))));

// Should also work for other unknown implementations of GraalVM
assertVersion(new Version("GraalVM 23.0", "23.0", GRAALVM), GRAALVM,
Version.of(Stream.of(("native-image 20 2023-07-30\n"
+ "Foo Runtime Environment whatever (build 20+34-jvmci-23.0-b7)\n"
+ "Foo VM whatever (build 20+34, serial gc)").split("\\n"))));
assertVersion(new Version("GraalVM 23.0", "23.0", GRAALVM), GRAALVM,
Version.of(Stream.of(("native-image 20 2023-07-30\n"
+ "Another Runtime Environment whatever (build 20+34-jvmci-23.0-b7)\n"
+ "Another VM whatever (build 20+34, serial gc)").split("\\n"))));

// Older version parsing
assertVersion(new Version("GraalVM 20.1", "20.1", GRAALVM), GRAALVM,
Version.of(Stream.of("GraalVM Version 20.1.0 (Java Version 11.0.7)")));
Expand Down Expand Up @@ -130,6 +140,19 @@ public void testGraalVM22DevVersionParser() {
assertThat(graalVM22Dev.javaVersion.update()).isEqualTo(0);
}

@Test
public void testGraalVMEE22DevVersionParser() {
Version graalVMEE22Dev = Version.of(Stream.of(("native-image 22 2024-03-19\n"
+ "Java(TM) SE Runtime Environment Oracle GraalVM 22-dev+25.1 (build 22+25-jvmci-b01)\n"
+ "Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 22-dev+25.1 (build 22+25-jvmci-b01, mixed mode, sharing)")
.split("\\n")));
assertThat(graalVMEE22Dev.distribution.name()).isEqualTo("GRAALVM");
assertThat(graalVMEE22Dev.getVersionAsString()).isEqualTo("24.0-dev");
assertThat(graalVMEE22Dev.javaVersion.toString()).isEqualTo("22+25-jvmci-b01");
assertThat(graalVMEE22Dev.javaVersion.feature()).isEqualTo(22);
assertThat(graalVMEE22Dev.javaVersion.update()).isEqualTo(0);
}

@Test
public void testGraalVMVersionsOlderThan() {
assertOlderThan("GraalVM Version 19.3.6 CE", "GraalVM Version 20.2.0 (Java Version 11.0.9)");
Expand Down

0 comments on commit 0b7462d

Please sign in to comment.