You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/04/01 15:53:28 UTC
[commons-lang] 01/02: Add SystemUtils.IS_JAVA_19
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 18e772ca54dda9eee10b15b235b5b4710d232777
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 1 11:48:25 2023 -0400
Add SystemUtils.IS_JAVA_19
---
src/changes/changes.xml | 1 +
.../java/org/apache/commons/lang3/SystemUtils.java | 13 +++++++++
.../org/apache/commons/lang3/SystemUtilsTest.java | 33 ++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4e7c2ea42..421e44b2c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -177,6 +177,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_16.</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>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_19.</action>
<action issue="LANG-1627" type="add" dev="ggregory" due-to="Alberto Scotto, Avijit Chakraborty, Steve Bosman, Bruno P. Kinoshita, Gary Gregory">Add ArrayUtils.oneHot().</action>
<action issue="LANG-1662" type="add" dev="ggregory" due-to="Daniel Augusto Veronezi Salvador, Gary Gregory, Bruno P. Kinoshita">Let ReflectionToStringBuilder only reflect given field names #849.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add Streams.of(Enumeration<E>).</action>
diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java
index 85a2bb443..95d936ec0 100644
--- a/src/main/java/org/apache/commons/lang3/SystemUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java
@@ -1071,6 +1071,19 @@ public class SystemUtils {
*/
public static final boolean IS_JAVA_18 = getJavaVersionMatches("18");
+ /**
+ * Is {@code true} if this is Java version 19 (also 19.x versions).
+ * <p>
+ * The field will return {@code false} if {@link #JAVA_VERSION} is {@code null}.
+ * </p>
+ * <p>
+ * This value is initialized when the class is loaded.
+ * </p>
+ *
+ * @since 3.13.0
+ */
+ public static final boolean IS_JAVA_19 = getJavaVersionMatches("19");
+
// 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 753de4dab..f62379c3e 100644
--- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java
@@ -76,6 +76,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("1.8")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -96,6 +97,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("9")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -116,6 +118,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("10")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -136,6 +139,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("11")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -156,6 +160,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("12")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -176,6 +181,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("13")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -196,6 +202,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("14")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -216,6 +223,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("15")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -236,6 +244,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("16")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -256,6 +265,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertTrue(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("17")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -276,6 +286,7 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertTrue(SystemUtils.IS_JAVA_17);
assertFalse(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
} else if (javaVersion.startsWith("18")) {
assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2);
@@ -296,6 +307,28 @@ public class SystemUtilsTest extends AbstractLangTest {
assertFalse(SystemUtils.IS_JAVA_16);
assertFalse(SystemUtils.IS_JAVA_17);
assertTrue(SystemUtils.IS_JAVA_18);
+ assertFalse(SystemUtils.IS_JAVA_19);
+ } else if (javaVersion.startsWith("19")) {
+ 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);
+ assertFalse(SystemUtils.IS_JAVA_18);
+ assertTrue(SystemUtils.IS_JAVA_19);
} else {
System.out.println("Can't test IS_JAVA value: " + javaVersion);
}