Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2016-03-07 09:37:58 -0500
committerJoakim Erdfelt2016-03-07 09:37:58 -0500
commit484d0a67169baedc9b933cdf7dd22a908e52d28f (patch)
tree5a68bdb8d58acaa9e0bbcca9b4e55827ce27e29b
parent0a5bffcfcee6c3266f2e8d1dfbeebb81b6914249 (diff)
parenta366c2804b4212fbb3ecbd9f1dc1c138098ce2ed (diff)
downloadorg.eclipse.jetty.toolchain-484d0a67169baedc9b933cdf7dd22a908e52d28f.tar.gz
org.eclipse.jetty.toolchain-484d0a67169baedc9b933cdf7dd22a908e52d28f.tar.xz
org.eclipse.jetty.toolchain-484d0a67169baedc9b933cdf7dd22a908e52d28f.zip
Merge pull request #3 from NitorCreations/master
Add support for parsing new style jdk9 and later version numbers
-rw-r--r--jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java8
-rw-r--r--jetty-test-helper/src/test/java/org/eclipse/jetty/toolchain/test/JDKTest.java9
2 files changed, 13 insertions, 4 deletions
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
index d9e0973..edbde45 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
@@ -40,9 +40,9 @@ public class JDK
*/
public static final boolean IS_8 = isJavaVersionAtLeast(1,8);
/**
- * True if JDK is 1.9 (or newer)
+ * True if JDK is 9.0 (or newer)
*/
- public static final boolean IS_9 = isJavaVersionAtLeast(1,9);
+ public static final boolean IS_9 = isJavaVersionAtLeast(9,0);
private static boolean isJavaVersionAtLeast(int maj, int min)
{
@@ -52,13 +52,13 @@ public class JDK
System.err.println("## ERROR: System.getProperty('java.version') == null !?");
return false;
}
- String vparts[] = jver.split("\\.");
+ String vparts[] = jver.split("[-.]");
if (vparts.length < 2)
{
System.err.println("## ERROR: Invalid java version format '" + jver + "'");
return false;
}
- return (toInt(vparts[0]) >= maj && toInt(vparts[1]) >= min);
+ return toInt(vparts[0]) > maj || (toInt(vparts[0]) == maj && toInt(vparts[1]) >= min);
}
private static int toInt(String val)
diff --git a/jetty-test-helper/src/test/java/org/eclipse/jetty/toolchain/test/JDKTest.java b/jetty-test-helper/src/test/java/org/eclipse/jetty/toolchain/test/JDKTest.java
index 90ee5d5..4330657 100644
--- a/jetty-test-helper/src/test/java/org/eclipse/jetty/toolchain/test/JDKTest.java
+++ b/jetty-test-helper/src/test/java/org/eclipse/jetty/toolchain/test/JDKTest.java
@@ -67,5 +67,14 @@ public class JDKTest
assertThat("JVM(" + ver + ") / JDK.IS_8",JDK.IS_8,is(true));
assertThat("JVM(" + ver + ") / JDK.IS_9",JDK.IS_9,is(false));
}
+ else if (ver.startsWith("9"))
+ {
+ System.err.println("Testing JDK.IS_9 - " + ver);
+ assertThat("JVM(" + ver + ") / JDK.IS_5",JDK.IS_5,is(true));
+ assertThat("JVM(" + ver + ") / JDK.IS_6",JDK.IS_6,is(true));
+ assertThat("JVM(" + ver + ") / JDK.IS_7",JDK.IS_7,is(true));
+ assertThat("JVM(" + ver + ") / JDK.IS_8",JDK.IS_8,is(true));
+ assertThat("JVM(" + ver + ") / JDK.IS_9",JDK.IS_9,is(true));
+ }
}
}

Back to the top