diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/JavaVersion.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/JavaVersion.java index feda02e009..3ebcfbf10f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/JavaVersion.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/JavaVersion.java @@ -21,6 +21,7 @@ import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.SortedSet; import java.util.concurrent.Future; import org.springframework.util.ClassUtils; @@ -53,7 +54,12 @@ public enum JavaVersion { /** * Java 20. */ - TWENTY("20", Class.class, "accessFlags"); + TWENTY("20", Class.class, "accessFlags"), + + /** + * Java 21. + */ + TWENTY_ONE("21", SortedSet.class, "getFirst"); private final String name; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/JavaVersionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/JavaVersionTests.java index 0b0787b9fe..d87c1230f7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/JavaVersionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/system/JavaVersionTests.java @@ -103,4 +103,10 @@ class JavaVersionTests { assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWENTY); } + @Test + @EnabledOnJre(JRE.JAVA_21) + void currentJavaVersionTwentyOne() { + assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWENTY_ONE); + } + }