Add TWENTY_ONE to JavaVersion

Closes gh-37362
pull/37394/head
Moritz Halbritter 1 year ago committed by Andy Wilkinson
parent 75233e9865
commit 13a3e3bdf0

@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.SortedSet;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -114,7 +115,13 @@ public enum JavaVersion {
* Java 20. * Java 20.
* @since 2.7.13 * @since 2.7.13
*/ */
TWENTY("20", Class.class, "accessFlags"); TWENTY("20", Class.class, "accessFlags"),
/**
* Java 21.
* @since 2.7.16
*/
TWENTY_ONE("21", SortedSet.class, "getFirst");
private final String name; private final String name;

@ -158,6 +158,12 @@ class JavaVersionTests {
assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWENTY); assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWENTY);
} }
@Test
@EnabledIf("java21")
void currentJavaVersionTwentyOne() {
assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWENTY_ONE);
}
static boolean java19() { static boolean java19() {
return "19".equals(System.getProperty("java.version")); return "19".equals(System.getProperty("java.version"));
} }
@ -166,4 +172,8 @@ class JavaVersionTests {
return System.getProperty("java.version").startsWith("20"); return System.getProperty("java.version").startsWith("20");
} }
static boolean java21() {
return System.getProperty("java.version").startsWith("21");
}
} }

Loading…
Cancel
Save