LANG-1103: Add SystemUtils.IS_JAVA_1_9

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1669753 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2015-03-28 12:26:01 +00:00
parent 11c0df1d9e
commit 3225ba64ce
3 changed files with 39 additions and 0 deletions

View File

@ -22,6 +22,7 @@
<body> <body>
<release version="3.4" date="tba" description="tba"> <release version="3.4" date="tba" description="tba">
<action issue="LANG-1103" type="add" dev="britter">Add SystemUtils.IS_JAVA_1_9</action>
<action issue="LANG-1102" type="update" dev="britter">Make logic for comparing OS versions in SystemUtils smarter</action> <action issue="LANG-1102" type="update" dev="britter">Make logic for comparing OS versions in SystemUtils smarter</action>
<action issue="LANG-1091" type="update" dev="britter" due-to="Fabian Lange">Shutdown thread pools in test cases</action> <action issue="LANG-1091" type="update" dev="britter" due-to="Fabian Lange">Shutdown thread pools in test cases</action>
<action issue="LANG-1101" type="update" dev="chas">FastDateParser and FastDatePrinter support 'X' format</action> <action issue="LANG-1101" type="update" dev="chas">FastDateParser and FastDatePrinter support 'X' format</action>

View File

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

View File

@ -105,6 +105,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.1")) { } else if (javaVersion.startsWith("1.1")) {
assertTrue(SystemUtils.IS_JAVA_1_1); assertTrue(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -113,6 +115,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.2")) { } else if (javaVersion.startsWith("1.2")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertTrue(SystemUtils.IS_JAVA_1_2); assertTrue(SystemUtils.IS_JAVA_1_2);
@ -121,6 +125,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.3")) { } else if (javaVersion.startsWith("1.3")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -129,6 +135,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.4")) { } else if (javaVersion.startsWith("1.4")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -137,6 +145,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.5")) { } else if (javaVersion.startsWith("1.5")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -145,6 +155,8 @@ public class SystemUtilsTest {
assertTrue(SystemUtils.IS_JAVA_1_5); assertTrue(SystemUtils.IS_JAVA_1_5);
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.6")) { } else if (javaVersion.startsWith("1.6")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -153,6 +165,8 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_5); assertFalse(SystemUtils.IS_JAVA_1_5);
assertTrue(SystemUtils.IS_JAVA_1_6); assertTrue(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.7")) { } else if (javaVersion.startsWith("1.7")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -162,6 +176,7 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertTrue(SystemUtils.IS_JAVA_1_7); assertTrue(SystemUtils.IS_JAVA_1_7);
assertFalse(SystemUtils.IS_JAVA_1_8); assertFalse(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.8")) { } else if (javaVersion.startsWith("1.8")) {
assertFalse(SystemUtils.IS_JAVA_1_1); assertFalse(SystemUtils.IS_JAVA_1_1);
assertFalse(SystemUtils.IS_JAVA_1_2); assertFalse(SystemUtils.IS_JAVA_1_2);
@ -171,6 +186,17 @@ public class SystemUtilsTest {
assertFalse(SystemUtils.IS_JAVA_1_6); assertFalse(SystemUtils.IS_JAVA_1_6);
assertFalse(SystemUtils.IS_JAVA_1_7); assertFalse(SystemUtils.IS_JAVA_1_7);
assertTrue(SystemUtils.IS_JAVA_1_8); assertTrue(SystemUtils.IS_JAVA_1_8);
assertFalse(SystemUtils.IS_JAVA_1_9);
} else if (javaVersion.startsWith("1.9")) {
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);
assertTrue(SystemUtils.IS_JAVA_1_9);
} else { } else {
System.out.println("Can't test IS_JAVA value: "+javaVersion); System.out.println("Can't test IS_JAVA value: "+javaVersion);
} }