Skip to content

Commit

Permalink
[GR-53458] JVMCIVersionCheck should only consider release and early-a…
Browse files Browse the repository at this point in the history
…ccess OpenJDK version

PullRequest: graal/17517
  • Loading branch information
zapster committed Apr 18, 2024
2 parents c8e9e12 + de871f0 commit c0959ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
*/
package jdk.graal.compiler.hotspot.test;

import org.junit.Assert;
import org.junit.Test;

import jdk.graal.compiler.core.test.GraalCompilerTest;
import jdk.graal.compiler.hotspot.JVMCIVersionCheck;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static jdk.graal.compiler.hotspot.JVMCIVersionCheck.DEFAULT_VENDOR_ENTRY;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import static jdk.graal.compiler.hotspot.JVMCIVersionCheck.DEFAULT_VENDOR_ENTRY;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import jdk.graal.compiler.core.test.GraalCompilerTest;
import jdk.graal.compiler.hotspot.JVMCIVersionCheck;

/**
* Tests that {@link JVMCIVersionCheck} handles OpenJDK versions correctly.
Expand All @@ -54,6 +54,18 @@ public static Collection<Object[]> data() {
expectFail("99+99-jvmci-b02", "99+98"),
expectPass("99+99-jvmci-b02", "99+99"),
expectPass("99+99-jvmci-b02", "99+100"),
/*
* Also if comparing against an OpenJDK early access version.
*/
expectFail("99+99-jvmci-b02", "99-ea+98"),
expectPass("99+99-jvmci-b02", "99-ea+99"),
expectPass("99+99-jvmci-b02", "99-ea+100"),
/*
* OpenJDK version with unknown $PRE value are ignored.
*/
expectPass("99+99-jvmci-b02", "99-something+98"),
expectPass("99+99-jvmci-b02", "99-something+99"),
expectPass("99+99-jvmci-b02", "99-something+100"),
/*
* If comparing a LabsJDK version against a LabsJDK version, respect the
* JVMCI build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ static Version parse(String vmVersion) {
}
} else {
try {
// assume OpenJDK version
return createOpenJDKVersion(stripVersion(vmVersion));
var rv = Runtime.Version.parse(vmVersion);
if (rv.pre().isEmpty() || "ea".equals(rv.pre().get())) {
// release or early access build
return createOpenJDKVersion(stripVersion(rv));
}
} catch (IllegalArgumentException e) {
// unexpected version string -> be on the safe side and ignore
}
Expand All @@ -130,8 +133,7 @@ static Version parse(String vmVersion) {
* Returns a {@linkplain java.lang.Runtime.Version version string} without
* {@link java.lang.Runtime.Version#pre()} and {@link java.lang.Runtime.Version#optional()}.
*/
private static String stripVersion(String versionString) {
var rv = Runtime.Version.parse(versionString);
private static String stripVersion(Runtime.Version rv) {
var sb = new StringBuilder(rv.version().stream().map(Object::toString).collect(Collectors.joining(".")));
if (rv.build().isPresent()) {
sb.append("+").append(rv.build().get());
Expand Down Expand Up @@ -322,7 +324,14 @@ private void run(boolean exitOnFailure, Version minVersion, PrintFormat format)
// Allow local builds
return;
}
// A "labsjdk"
if (!vmVersion.contains("-jvmci-")) {
var rv = Runtime.Version.parse(vmVersion);
if (rv.pre().isPresent() && !"ea".equals(rv.pre().get())) {
// Not a release or early access OpenJDK version
return;
}
}
// A "labsjdk" or a known OpenJDK
if (minVersion == null) {
failVersionCheck(exitOnFailure, "No minimum JVMCI version specified for JDK version %s.%n", javaSpecVersion);
}
Expand Down

0 comments on commit c0959ee

Please sign in to comment.