From 280ce6390a81ea9ca5ef9455ad8b619bf766480b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 8 Sep 2022 15:25:34 +0100 Subject: [PATCH] Add NINETEEN to JavaVersion enum Closes gh-32226 --- .../org/springframework/boot/system/JavaVersion.java | 8 +++++++- .../springframework/boot/system/JavaVersionTests.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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 eedfe30b49..773c8d7bd9 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 @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.concurrent.Future; import java.util.stream.Stream; import org.springframework.util.ClassUtils; @@ -89,7 +90,12 @@ public enum JavaVersion { /** * Java 18. */ - EIGHTEEN("18", Duration.class, "isPositive"); + EIGHTEEN("18", Duration.class, "isPositive"), + + /** + * Java 19. + */ + NINETEEN("19", Future.class, "state"); 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 0793f99b4e..2cf29cc4cd 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 @@ -17,6 +17,7 @@ package org.springframework.boot.system; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIf; import org.junit.jupiter.api.condition.EnabledOnJre; import org.junit.jupiter.api.condition.JRE; @@ -145,4 +146,14 @@ class JavaVersionTests { assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.EIGHTEEN); } + @Test + @EnabledIf("java19") + void currentJavaVersionNineteen() { + assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.NINETEEN); + } + + static boolean java19() { + return "19".equals(System.getProperty("java.version")); + } + }