public static <T> T newInstance(final String className, ClassLoader cl) { Object o = __primitiveInstances.get(className); if (null != o) return (T) o; try { Class<T> c = (Class<T>) Class.forName(className, true, cl); return c.newInstance(); } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } }
public UnexpectedNewInstanceException(Exception cause) { super(triage(cause)); }
public static <T> T newInstance(final String className, ClassLoader cl) { Object o = __primitiveInstances.get(className); if (null != o) return (T) o; try { Class<T> c = (Class<T>) Class.forName(className, true, cl); return c.newInstance(); } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } }
public UnexpectedNewInstanceException(Exception cause) { super(triage(cause)); }
public static <T> T newInstance(final String className) { Object o = __primitiveInstances.get(className); if (null != o) return (T) o; // see http://stackoverflow.com/questions/27719295/java-lang-internalerror-callersensitive-annotation-expected-at-frame-1 return new SecurityManager() { private T t; { try { Class caller = getClassContext()[3]; Class<T> c = (Class<T>) Class.forName(className, true, caller.getClassLoader()); t = c.newInstance(); } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } } }.t; }
public UnexpectedNewInstanceException(Exception cause, String message, Object... args) { super(triage(cause), message, args); }
public static <T> T newInstance(final String className) { Object o = __primitiveInstances.get(className); if (null != o) return (T) o; // see http://stackoverflow.com/questions/27719295/java-lang-internalerror-callersensitive-annotation-expected-at-frame-1 return new SecurityManager() { private T t; { try { Class caller = getClassContext()[3]; Class<T> c = (Class<T>) Class.forName(className, true, caller.getClassLoader()); t = c.newInstance(); } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } } }.t; }
public UnexpectedNewInstanceException(Exception cause, String message, Object... args) { super(triage(cause), message, args); }
public static <T, P1> T newInstance(Class<T> c, P1 p1) { try { Constructor[] ca = c.getDeclaredConstructors(); for (Constructor<T> ct : ca) { Class[] pts = ct.getParameterTypes(); if (pts.length != 1 && !ct.isVarArgs()) { continue; } if (!testMethodParamType(pts, p1, 0)) { continue; } return ct.newInstance(p1); } throw new UnexpectedNewInstanceException("Constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } }
public static <T, P1> T newInstance(Class<T> c, P1 p1) { try { Constructor[] ca = c.getDeclaredConstructors(); for (Constructor<T> ct : ca) { Class[] pts = ct.getParameterTypes(); if (pts.length != 1 && !ct.isVarArgs()) { continue; } if (!testMethodParamType(pts, p1, 0)) { continue; } return ct.newInstance(p1); } throw new UnexpectedNewInstanceException("Constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new UnexpectedNewInstanceException(e); } }
return ct.newInstance(p1, p2); throw new UnexpectedNewInstanceException("constructor not found"); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e);
throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
return ct.newInstance(p1, p2); throw new UnexpectedNewInstanceException("constructor not found"); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e);
throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());
throw new UnexpectedNewInstanceException("constructor not found on " + c.getName()); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw ((RuntimeException) t); } else { throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName()); throw new UnexpectedNewInstanceException(e, "error instantiate instance of " + c.getName());