Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GraalVM version checker in order to accept other implementations #37651

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading