Skip to content
Permalink
Browse files
1011: Allow JDK fixVersion to be XXu-cpu
Reviewed-by: ehelin, kcr
  • Loading branch information
erikj79 committed May 4, 2021
1 parent fb532a0 commit 26948592ebe1aa72e05bad599d93a6099a0a79e8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
@@ -38,6 +38,9 @@ public class JdkVersion implements Comparable<JdkVersion> {
private final static Pattern ojVersionPattern = Pattern.compile("(openjdk[1-9][0-9]?)(u([0-9]{1,3}))?$");
private final static Pattern fxVersionPattern = Pattern.compile("(openjfx[1-9][0-9]?)(u([0-9]{1,3}))?$");

// Match a version string symbolizing some future, but yet undefined, update of a major version
private final static Pattern futureUpdatePattern = Pattern.compile("([1-9][0-9]*u)(-([a-z0-9]+))?$");

private final static Pattern prefixPattern = Pattern.compile("([a-z]+)([0-9.]+)$");

private final static Pattern legacyPrefixPattern = Pattern.compile("^([^\\d]*)\\d+$");
@@ -57,6 +60,19 @@ private static List<String> splitComponents(String raw) {
}
}

// Check special placeholder versions
if (finalComponents.isEmpty()) {
var matcher = futureUpdatePattern.matcher(raw);
if (matcher.matches()) {
finalComponents.add(matcher.group(1));
// Group 3 is the opt field
if (matcher.group(3) != null) {
finalComponents.add(null);
finalComponents.add(matcher.group(3));
}
}
}

// If no legacy match, use the JEP322 scheme
if (finalComponents.isEmpty()) {
var optionalStart = raw.lastIndexOf("-");
@@ -791,4 +791,18 @@ void test8u270(TestInfo testInfo) throws IOException {
backports.assertLabeled("8u281");
}
}

/**
* Verify that a release such as 16u-cpu does not ever get labeled.
*/
@Test
void uCpu(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "17");
backports.assertLabeled();

backports.addBackports("16", "16.0.2", "16u-cpu");
backports.assertLabeled("16.0.2", "17");
}
}
}
@@ -71,6 +71,15 @@ void openjfx11() {
assertEquals(List.of("openjfx17", "3", "4", "5", "6"), from("openjfx17.3.4.5.6").components());
}


@Test
void futureUpdates() {
assertEquals(List.of("16u"), from("16u").components());
var jdk16uCpu = from("16u-cpu");
assertEquals(List.of("16u"), jdk16uCpu.components());
assertEquals("cpu", jdk16uCpu.opt().orElseThrow());
}

@Test
void order() {
assertEquals(0, from("5.0u45").compareTo(from("5.0u45")));
@@ -92,11 +101,16 @@ void order() {
assertEquals(-1, from("openjfx11.0.12").compareTo(from("openjfx17.3.4.5.6")));
}

@Test
void cpuOrder() {
assertEquals(-1, from("16").compareTo(from("16u-cpu")));
assertEquals(-1, from("16.0.2").compareTo(from("16u-cpu")));
assertEquals(1, from("17").compareTo(from("16u-cpu")));
}

@Test
void nonConforming() {
assertEquals(Optional.empty(), JdkVersion.parse("bla"));
assertEquals(Optional.empty(), JdkVersion.parse(""));
assertEquals(Optional.empty(), JdkVersion.parse("12u-cpu"));
assertEquals(Optional.empty(), JdkVersion.parse("13u-open"));
}
}

1 comment on commit 2694859

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 2694859 May 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.