Skip to content

Commit

Permalink
Fix GrasalVM version checker in order to accept other implementations
Browse files Browse the repository at this point in the history
(cherry picked from commit b4eb722)
  • Loading branch information
brunocaballero authored and gsmet committed Dec 12, 2023
1 parent 181942d commit de9e90c
Show file tree
Hide file tree
Showing 2 changed files with 12 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

0 comments on commit de9e90c

Please sign in to comment.