Skip to content

Commit

Permalink
Handle GraalVM EA versions and update GraalVM version mapping
Browse files Browse the repository at this point in the history
* EA versions can result from quick builds running `mx build`
on substratevm and using labs JDK EA builds.
* Update GraalVM version mapping according to Christian Wimmer's
latest information. He indicated that upcoming JDK 24 will be
GraalVM 24.2, and then by JDK 25 version numbers will lineup.
  • Loading branch information
galderz committed Aug 14, 2024
1 parent baf77db commit 68dbddb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class GraalVM {
// Implements version parsing after https://github.com/oracle/graal/pull/6302
static final class VersionParseHelper {

private static final String EA_BUILD_PREFIX = "-ea";
private static final String JVMCI_BUILD_PREFIX = "jvmci-";
private static final String MANDREL_VERS_PREFIX = "Mandrel-";

Expand Down Expand Up @@ -103,11 +104,10 @@ private static String libericaVersion(String vendorVersion) {
if (vendorVersion == null) {
return null;
}
int idx = vendorVersion.indexOf(LIBERICA_NIK_VERS_PREFIX);
if (idx < 0) {
final String version = buildVersion(vendorVersion, LIBERICA_NIK_VERS_PREFIX);
if (version == null) {
return null;
}
String version = vendorVersion.substring(idx + LIBERICA_NIK_VERS_PREFIX.length());
return matchVersion(version);
}

Expand All @@ -122,11 +122,10 @@ private static String mandrelVersion(String vendorVersion) {
if (vendorVersion == null) {
return null;
}
int idx = vendorVersion.indexOf(MANDREL_VERS_PREFIX);
if (idx < 0) {
final String version = buildVersion(vendorVersion, MANDREL_VERS_PREFIX);
if (version == null) {
return null;
}
String version = vendorVersion.substring(idx + MANDREL_VERS_PREFIX.length());
return matchVersion(version);
}

Expand All @@ -142,27 +141,37 @@ private static String graalVersion(String buildInfo, int jdkFeature) {
if (buildInfo == null) {
return null;
}
int idx = buildInfo.indexOf(JVMCI_BUILD_PREFIX);
if (idx < 0) {
return null;
String version = buildVersion(buildInfo, JVMCI_BUILD_PREFIX);
if (version == null) {
version = buildVersion(buildInfo, EA_BUILD_PREFIX);
if (version == null) {
return null;
}
}
String version = buildInfo.substring(idx + JVMCI_BUILD_PREFIX.length());
Matcher versMatcher = VERSION_PATTERN.matcher(version);
if (versMatcher.find()) {
return matchVersion(version);
} else {
return GRAAL_MAPPING.get(jdkFeature);
}
}

private static String buildVersion(String buildInfo, String buildPrefix) {
int idx = buildInfo.indexOf(buildPrefix);
if (idx < 0) {
return null;
}
return buildInfo.substring(idx + buildPrefix.length());
}
}

// Temporarily work around https://github.com/quarkusio/quarkus/issues/36246,
// till we have a consensus on how to move forward in
// https://github.com/quarkusio/quarkus/issues/34161
private static final Map<Integer, String> GRAAL_MAPPING = Map.of(22, "24.0",
23, "24.1",
24, "25.0",
25, "25.1");
24, "24.2",
25, "25.0");

public static final class Version implements Comparable<Version> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ public void testGraalVMEE22DevVersionParser() {
assertThat(graalVMEE22Dev.javaVersion.update()).isEqualTo(0);
}

@Test
public void testGraalVMEA24DevVersionParser() {
final Version graalVMEA24Dev = Version.of(Stream.of(("native-image 24-ea 2025-03-18\n"
+ "OpenJDK Runtime Environment Oracle GraalVM 24-dev.ea+10.1 (build 24-ea+10-1076)\n"
+ "OpenJDK 64-Bit Server VM Oracle GraalVM 24-dev.ea+10.1 (build 24-ea+10-1076, mixed mode, sharing)")
.split("\\n")));
assertThat(graalVMEA24Dev.distribution.name()).isEqualTo("GRAALVM");
assertThat(graalVMEA24Dev.getVersionAsString()).isEqualTo("24.2-dev");
assertThat(graalVMEA24Dev.javaVersion.toString()).isEqualTo("24-ea+10-1076");
assertThat(graalVMEA24Dev.javaVersion.feature()).isEqualTo(24);
assertThat(graalVMEA24Dev.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 68dbddb

Please sign in to comment.