Add SystemUtils.IS_JAVA_16.

This commit is contained in:
Gary Gregory 2021-08-31 11:26:17 -04:00
parent ff1209f00f
commit 9e6383cb21
3 changed files with 40 additions and 0 deletions

View File

@ -81,6 +81,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedTimeoutException.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add UncheckedInterruptedException.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add TimeZones.GMT.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_16.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump spotbugs-maven-plugin from 4.2.0 to 4.2.3 #735.</action>
<action type="update" dev="ggregory" due-to="Dependabot, XenoAmess">Bump Bump actions/cache from v2.1.4 to v2.1.6 #742, #752, #764.</action>

View File

@ -1050,6 +1050,16 @@ public class SystemUtils {
*/
public static final boolean IS_JAVA_15 = getJavaVersionMatches("15");
/**
* Is {@code true} if this is Java version 16 (also 16.x versions).
* <p>
* The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}.
* </p>
*
* @since 3.13.0
*/
public static final boolean IS_JAVA_16 = getJavaVersionMatches("16");
// Operating system checks
// -----------------------------------------------------------------------
// These MUST be declared after those above as they depend on the

View File

@ -73,6 +73,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("1.8")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -90,6 +91,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("9")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -107,6 +109,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("10")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -124,6 +127,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("11")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -141,6 +145,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("12")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -156,6 +161,9 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_11);
assertTrue(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("13")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -173,6 +181,7 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("14")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -190,6 +199,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertTrue(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("15")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@ -207,6 +217,25 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertTrue(SystemUtils.IS_JAVA_15);
assertFalse(SystemUtils.IS_JAVA_16);
} else if (javaVersion.startsWith("16")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
assertFalse(SystemUtils.IS_JAVA_1_3);
assertFalse(SystemUtils.IS_JAVA_1_4);
assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
assertFalse(SystemUtils.IS_JAVA_9);
assertFalse(SystemUtils.IS_JAVA_10);
assertFalse(SystemUtils.IS_JAVA_11);
assertFalse(SystemUtils.IS_JAVA_12);
assertFalse(SystemUtils.IS_JAVA_13);
assertFalse(SystemUtils.IS_JAVA_14);
assertFalse(SystemUtils.IS_JAVA_15);
assertTrue(SystemUtils.IS_JAVA_16);
} else {
System.out.println("Can't test IS_JAVA value: " + javaVersion);
}