@Test public void testParseJavaVersion() { int[] ver; ver = Capsule.parseJavaVersion("8"); assertArrayEquals(ver, ints(1, 8, 0, 0, 0)); assertEquals("1.8.0", Capsule.toJavaVersionString(ver)); ver = Capsule.parseJavaVersion("1.8.0"); assertArrayEquals(ver, ints(1, 8, 0, 0, 0)); assertEquals("1.8.0", Capsule.toJavaVersionString(ver)); ver = Capsule.parseJavaVersion("1.8"); assertArrayEquals(ver, ints(1, 8, 0, 0, 0)); assertEquals("1.8.0", Capsule.toJavaVersionString(ver)); ver = Capsule.parseJavaVersion("1.8.0_30"); assertArrayEquals(ver, ints(1, 8, 0, 30, 0)); assertEquals("1.8.0_30", Capsule.toJavaVersionString(ver)); ver = Capsule.parseJavaVersion("1.8.0-rc"); assertArrayEquals(ver, ints(1, 8, 0, 0, -1)); assertEquals("1.8.0-rc", Capsule.toJavaVersionString(ver)); ver = Capsule.parseJavaVersion("1.8.0_30-ea"); assertArrayEquals(ver, ints(1, 8, 0, 30, -3)); assertEquals("1.8.0_30-ea", Capsule.toJavaVersionString(ver)); }
static int[] parseJavaVersion(String v) { final Matcher m = PAT_JAVA_VERSION.matcher(v); if (!m.matches()) throw new IllegalArgumentException("Could not parse version: " + v); final int[] ver = new int[5]; ver[0] = toInt(m.group("major")); ver[1] = toInt(m.group("minor")); ver[2] = toInt(m.group("patch")); ver[3] = toInt(m.group("update")); if (ver[0] > 1 && ver[1] == 0) { ver[1] = ver[0]; ver[0] = 1; } final String pre = m.group("pre"); if (pre != null) { if (pre.startsWith("rc")) ver[4] = -1; else if (pre.startsWith("beta")) ver[4] = -2; else if (pre.startsWith("ea")) ver[4] = -3; } return ver; }
Capsule implements Runnable, InvocationHandler { static int[] parseJavaVersion(String v) { final Matcher m = PAT_JAVA_VERSION.matcher(v); if (!m.matches()) throw new IllegalArgumentException("Could not parse version: " + v); final int[] ver = new int[5]; ver[0] = toInt(m.group("major")); ver[1] = toInt(m.group("minor")); ver[2] = toInt(m.group("patch")); ver[3] = toInt(m.group("update")); if (ver[0] > 1 && ver[1] == 0) { ver[1] = ver[0]; ver[0] = 1; } final String pre = m.group("pre"); if (pre != null) { if (pre.startsWith("rc")) ver[4] = -1; else if (pre.startsWith("beta")) ver[4] = -2; else if (pre.startsWith("ea")) ver[4] = -3; } return ver; } }
Capsule implements Runnable, InvocationHandler { static int[] parseJavaVersion(String v) { final Matcher m = PAT_JAVA_VERSION.matcher(v); if (!m.matches()) throw new IllegalArgumentException("Could not parse version: " + v); final int[] ver = new int[5]; ver[0] = toInt(m.group("major")); ver[1] = toInt(m.group("minor")); ver[2] = toInt(m.group("patch")); ver[3] = toInt(m.group("update")); if (ver[0] > 1 && ver[1] == 0) { ver[1] = ver[0]; ver[0] = 1; } final String pre = m.group("pre"); if (pre != null) { if (pre.startsWith("rc")) ver[4] = -1; else if (pre.startsWith("beta")) ver[4] = -2; else if (pre.startsWith("ea")) ver[4] = -3; } return ver; } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); }
Capsule implements Runnable, InvocationHandler { static int[] parseJavaVersion(String v) { final Matcher m = PAT_JAVA_VERSION.matcher(v); if (!m.matches()) throw new IllegalArgumentException("Could not parse version: " + v); final int[] ver = new int[5]; ver[0] = toInt(m.group("major")); ver[1] = toInt(m.group("minor")); ver[2] = toInt(m.group("patch")); ver[3] = toInt(m.group("update")); if (ver[0] > 1 && ver[1] == 0) { ver[1] = ver[0]; ver[0] = 1; } final String pre = m.group("pre"); if (pre != null) { if (pre.startsWith("rc")) ver[4] = -1; else if (pre.startsWith("beta")) ver[4] = -2; else if (pre.startsWith("ea")) ver[4] = -3; } return ver; } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); }
Capsule implements Runnable, InvocationHandler { static int[] parseJavaVersion(String v) { final Matcher m = PAT_JAVA_VERSION.matcher(v); if (!m.matches()) throw new IllegalArgumentException("Could not parse version: " + v); final int[] ver = new int[5]; ver[0] = toInt(m.group("major")); ver[1] = toInt(m.group("minor")); ver[2] = toInt(m.group("patch")); ver[3] = toInt(m.group("update")); if (ver[0] > 1 && ver[1] == 0) { ver[1] = ver[0]; ver[0] = 1; } final String pre = m.group("pre"); if (pre != null) { if (pre.startsWith("rc")) ver[4] = -1; else if (pre.startsWith("beta")) ver[4] = -2; else if (pre.startsWith("ea")) ver[4] = -3; } return ver; } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); static final String VERSION; }