@Test public void testShortJavaVersion() { assertEquals("1.8.0", Capsule.shortJavaVersion("8")); assertEquals("1.8.0", Capsule.shortJavaVersion("1.8")); assertEquals("1.8.0", Capsule.shortJavaVersion("1.8.0")); }
static String shortJavaVersion(String v) { try { final String[] vs = v.split(SEPARATOR_DOT); if (vs.length == 1) { if (Integer.parseInt(vs[0]) < 5) throw new RuntimeException("Unrecognized major Java version: " + v); v = "1." + v + ".0"; } if (vs.length == 2) v += ".0"; return v; } catch (NumberFormatException e) { return null; } }
Capsule implements Runnable, InvocationHandler { static String shortJavaVersion(String v) { try { final String[] vs = v.split(SEPARATOR_DOT); if (vs.length == 1) { if (Integer.parseInt(vs[0]) < 5) throw new RuntimeException("Unrecognized major Java version: " + v); v = "1." + v + ".0"; } if (vs.length == 2) v += ".0"; return v; } catch (NumberFormatException e) { return null; } } }
Capsule implements Runnable, InvocationHandler { static String shortJavaVersion(String v) { try { final String[] vs = v.split(SEPARATOR_DOT); if (vs.length == 1) { if (Integer.parseInt(vs[0]) < 5) throw new RuntimeException("Unrecognized major Java version: " + v); v = "1." + v + ".0"; } if (vs.length == 2) v += ".0"; return v; } catch (NumberFormatException e) { return null; } } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); }
Capsule implements Runnable, InvocationHandler { static String shortJavaVersion(String v) { try { final String[] vs = v.split(SEPARATOR_DOT); if (vs.length == 1) { if (Integer.parseInt(vs[0]) < 5) throw new RuntimeException("Unrecognized major Java version: " + v); v = "1." + v + ".0"; } if (vs.length == 2) v += ".0"; return v; } catch (NumberFormatException e) { return null; } } @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 String shortJavaVersion(String v) { try { final String[] vs = v.split(SEPARATOR_DOT); if (vs.length == 1) { if (Integer.parseInt(vs[0]) < 5) throw new RuntimeException("Unrecognized major Java version: " + v); v = "1." + v + ".0"; } if (vs.length == 2) v += ".0"; return v; } catch (NumberFormatException e) { return null; } } @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; }