This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit e5e8ba09066fadb13d6b84402d46287bbd1569b7 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue Jul 5 10:29:51 2022 -0400 Add SystemUtils.IS_JAVA_18 --- src/changes/changes.xml | 1 + .../java/org/apache/commons/lang3/SystemUtils.java | 10 +++++++ .../org/apache/commons/lang3/SystemUtilsTest.java | 31 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1b7ca9fe7..d344dd707 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -153,6 +153,7 @@ The <action> type attribute can be add,update,fix,remove. <action type="add" dev="ggregory" due-to="Gary Gregory">Add ExceptionUtils.getRootCauseStackTraceList(Throwable).</action> <action type="add" dev="ggregory" due-to="Will Herrmann, Gary Gregory, Roland Kreuzer">Add SystemUtils.IS_OS_WINDOWS_11.</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_17.</action> + <action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_18.</action> <!-- UPDATE --> <action type="update" dev="ggregory" due-to="Dependabot, XenoAmess, Gary Gregory">Bump actions/cache from 2.1.4 to 3.0.4 #742, #752, #764, #833, #867.</action> <action type="update" dev="ggregory" due-to="Dependabot">Bump actions/checkout from 2 to 3 #819, #825, #859.</action> diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index 12db15573..2b9bec638 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -1070,6 +1070,16 @@ public class SystemUtils { */ public static final boolean IS_JAVA_17 = getJavaVersionMatches("17"); + /** + * Is {@code true} if this is Java version 18 (also 18.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_18 = getJavaVersionMatches("18"); + // 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 61237a232..208997daa 100644 --- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java @@ -75,6 +75,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("1.8")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -94,6 +95,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("9")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -113,6 +115,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("10")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -132,6 +135,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("11")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -151,6 +155,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("12")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -170,6 +175,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("13")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -189,6 +195,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("14")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -208,6 +215,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("15")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -227,6 +235,7 @@ public class SystemUtilsTest { assertTrue(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("16")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -246,6 +255,7 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertTrue(SystemUtils.IS_JAVA_16); assertFalse(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); } else if (javaVersion.startsWith("17")) { assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_2); @@ -265,6 +275,27 @@ public class SystemUtilsTest { assertFalse(SystemUtils.IS_JAVA_15); assertFalse(SystemUtils.IS_JAVA_16); assertTrue(SystemUtils.IS_JAVA_17); + assertFalse(SystemUtils.IS_JAVA_18); + } else if (javaVersion.startsWith("18")) { + 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); + assertFalse(SystemUtils.IS_JAVA_16); + assertFalse(SystemUtils.IS_JAVA_17); + assertTrue(SystemUtils.IS_JAVA_18); } else { System.out.println("Can't test IS_JAVA value: " + javaVersion); }