From 9de03491abb6af7f7539674a05044b917805c066 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 4 Jan 2016 12:48:59 -0800 Subject: [PATCH] Cope with java version becoming 9.X rather than 1.9.X --- .../newsrc/org/aspectj/testing/AjcTest.java | 2 +- util/src/org/aspectj/util/LangUtil.java | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/testing/newsrc/org/aspectj/testing/AjcTest.java b/testing/newsrc/org/aspectj/testing/AjcTest.java index 57129c853..29d3d1786 100644 --- a/testing/newsrc/org/aspectj/testing/AjcTest.java +++ b/testing/newsrc/org/aspectj/testing/AjcTest.java @@ -47,7 +47,7 @@ public class AjcTest { is16VMOrGreater = true; is17VMOrGreater = true; is18VMOrGreater = true; - } else if (vm.startsWith("1.9")) { + } else if (vm.startsWith("1.9") || vm.startsWith("9")) { is15VMOrGreater = true; is16VMOrGreater = true; is17VMOrGreater = true; diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java index cf929b7b5..49caba6b7 100644 --- a/util/src/org/aspectj/util/LangUtil.java +++ b/util/src/org/aspectj/util/LangUtil.java @@ -71,12 +71,17 @@ public class LangUtil { .printStackTrace(System.err); vmVersion = 1.5; } else { - try { - String versionString = vm.substring(0, 3); - Double temp = new Double(Double.parseDouble(versionString)); - vmVersion = temp.doubleValue(); - } catch (Exception e) { - vmVersion = 1.4; + if (vm.startsWith("9")) { + // JDK 9 beta 99 starts using 9-ea as the version string. + vmVersion = 1.9; + } else { + try { + String versionString = vm.substring(0, 3); + Double temp = new Double(Double.parseDouble(versionString)); + vmVersion = temp.doubleValue(); + } catch (Exception e) { + vmVersion = 1.4; + } } } } catch (Throwable t) { @@ -110,6 +115,10 @@ public class LangUtil { public static boolean is18VMOrGreater() { return 1.8 <= vmVersion; } + + public static boolean is19VMOrGreater() { + return 1.9 <= vmVersion; + } /** * Shorthand for "if null, throw IllegalArgumentException" -- 2.39.5