From 0ea3b9246a9582f4015c8f4655dc57c0ea4172ca Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sat, 5 Jun 2021 09:39:58 +0200 Subject: [PATCH] Add Java 17 to JavaVersion enum See gh-26769 --- .../org/springframework/boot/system/JavaVersion.java | 10 ++++++++-- .../springframework/boot/system/JavaVersionTests.java | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) 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 1592c6b0ac..17a635d17e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.boot.system; +import java.io.Console; import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.Collections; @@ -77,7 +78,12 @@ public enum JavaVersion { /** * Java 16. */ - SIXTEEN("16", Stream.class, "toList"); + SIXTEEN("16", Stream.class, "toList"), + + /** + * Java 17. + */ + SEVENTEEN("17", Console.class, "charset"); 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 f464ecce1b..8bcbfd0414 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,4 +133,10 @@ class JavaVersionTests { assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.SIXTEEN); } + @Test + @EnabledOnJre(JRE.JAVA_17) + void currentJavaVersionSeventeen() { + assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.SEVENTEEN); + } + }