diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 56b6041d6..2a307cb55 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -93,6 +93,7 @@ The type attribute can be add,update,fix,remove. Add org.apache.commons.lang3.SystemUtils.getUserName(). Add ObjectToStringComparator. #483. Add org.apache.commons.lang3.arch.Processor.Arch.getLabel(). + Add IS_JAVA_14 and IS_JAVA_15 to org.apache.commons.lang3.SystemUtils. diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index 6abb09e8a..e3c300c3e 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -1026,6 +1026,30 @@ public class SystemUtils { */ public static final boolean IS_JAVA_13 = getJavaVersionMatches("13"); + /** + *

+ * Is {@code true} if this is Java version 14 (also 14.x versions). + *

+ *

+ * The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}. + *

+ * + * @since 3.10 + */ + public static final boolean IS_JAVA_14 = getJavaVersionMatches("14"); + + /** + *

+ * Is {@code true} if this is Java version 15 (also 15.x versions). + *

+ *

+ * The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}. + *

+ * + * @since 3.10 + */ + public static final boolean IS_JAVA_15 = getJavaVersionMatches("15"); + // Operating system checks // ----------------------------------------------------------------------- // These MUST be declared after those above as they depend on the diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java index c39ebd617..be5af2d00 100644 --- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java @@ -155,6 +155,8 @@ public class SystemUtilsTest { 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); } else if (javaVersion.startsWith("1.8")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -170,6 +172,8 @@ public class SystemUtilsTest { 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); } else if (javaVersion.startsWith("9")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -185,6 +189,8 @@ public class SystemUtilsTest { 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); } else if (javaVersion.startsWith("10")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -200,6 +206,8 @@ public class SystemUtilsTest { 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); } else if (javaVersion.startsWith("11")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -215,6 +223,8 @@ public class SystemUtilsTest { assertTrue(SystemUtils.IS_JAVA_11); assertFalse(SystemUtils.IS_JAVA_12); assertFalse(SystemUtils.IS_JAVA_13); + assertFalse(SystemUtils.IS_JAVA_14); + assertFalse(SystemUtils.IS_JAVA_15); } else if (javaVersion.startsWith("12")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -245,6 +255,42 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_11); assertFalse(SystemUtils.IS_JAVA_12); assertTrue(SystemUtils.IS_JAVA_13); + assertFalse(SystemUtils.IS_JAVA_14); + assertFalse(SystemUtils.IS_JAVA_15); + } else if (javaVersion.startsWith("14")) { + 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); + assertTrue(SystemUtils.IS_JAVA_14); + assertFalse(SystemUtils.IS_JAVA_15); + } else if (javaVersion.startsWith("15")) { + 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); + assertTrue(SystemUtils.IS_JAVA_15); } else { System.out.println("Can't test IS_JAVA value: " + javaVersion); }