[java-support] branch master updated: JPAR-103 - Support Java 10

Ian Young ian at iay.org.uk
Wed Feb 21 11:21:11 EST 2018


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=bba06282d53dda9d61d47b2172253fc06cae13b2

The following commit(s) were added to refs/heads/master by this push:
       new  bba0628   JPAR-103 - Support Java 10
bba0628 is described below

commit bba06282d53dda9d61d47b2172253fc06cae13b2
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Feb 21 16:21:06 2018 +0000

    JPAR-103 - Support Java 10
    
    Allow for version strings like "10+43".
---
 .../java/support/testing/TestSupport.java          | 43 +++++++++++++++++++++-
 .../java/support/testing/TestSupportTest.java      |  1 +
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupport.java b/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupport.java
index aaecdc0..5e82788 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupport.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupport.java
@@ -55,16 +55,55 @@ public class TestSupport {
      * This is not part of the API of the class, but is available as
      * a protected method for self-testing.
      *
+     * The version string given by the <code>java.version</code>
+     * property has changed format multiple times in its history.
+     * This method acts as a parser for such strings. It is only
+     * required to handle versions of Java from the current platform
+     * baseline onwards (and thus their particular version string
+     * quirks) but in practice may support previous versions.
+     *
+     * For Java 6, 7 and 8, the version string has a format
+     * like "1.X.0_123" where X is the version of Java. This means
+     * that there will always be at least two components separated
+     * by periods, and that the first such component will always
+     * be "1".
+     *
+     * Examples of versions strings observed in practice:
+     *
+     * <ul>
+     * <li><code>1.6.0_65-b14-468</code>
+     * <li><code>1.7.0_51</code>
+     * <li><code>1.8.0_144</code>
+     * </ul>
+     *
+     * For Java 9, the version string format is described in
+     * <a href="http://openjdk.java.net/jeps/223">JEP 223</a>.
+     *
+     * For Java 10, the version string format is described in
+     * <a href="http://openjdk.java.net/jeps/322">JEP 322</a>
+     *
+     * Both JEP 223 and JEP 322 allow for an arbitrary number of numeric
+     * components separated by periods, but the possibility exists for this
+     * to be a <em>single</em> component. Following this a number of other
+     * components delimited by either <code>+</code> or <code>-</code> may
+     * appear. This means that version strings like "10+43" are possible, and
+     * have been observed.
+     *
      * @param versionStr version string to extract the version from
      * @return the major version number
+     *
+     * @see <a href="http://openjdk.java.net/jeps/223">JEP 223</a>
+     * @see <a href="http://openjdk.java.net/jeps/322">JEP 322</a>
      */
     protected static int getJavaVersion(@Nonnull final String versionStr) {
-        final String components[] = versionStr.split("\\.");
+        // Split into components delimited by '.', '+' and '-'.
+        // This covers both the historic, JEP 223 and JEP 332 schemes.
+        final String components[] = versionStr.split("\\.|\\+|-");
         if (components[0].equals("1")) {
             // Handle 1.6, 1.7, 1.8
             return Integer.parseInt(components[1]);
         } else {
-            // e.g., 9, 9.0.1
+            // e.g., 9, 9.0.1, 10+43
             return Integer.parseInt(components[0]);
         }
     }
diff --git a/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupportTest.java b/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupportTest.java
index 74b5793..cc987f1 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupportTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/testing/TestSupportTest.java
@@ -32,6 +32,7 @@ public class TestSupportTest {
         Assert.assertEquals(TestSupport.getJavaVersion("1.8.0_144"), 8);
         Assert.assertEquals(TestSupport.getJavaVersion("9"), 9);
         Assert.assertEquals(TestSupport.getJavaVersion("9.0.1"), 9);
+        Assert.assertEquals(TestSupport.getJavaVersion("10+43"), 10); // Java 10 RC
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list