public static <T> T instantiate(Constructor<T> ctor, Object... args) { try { return ctor.newInstance(args); } catch (Exception e) { String msg = "Unable to instantiate instance with constructor [" + ctor + "]"; throw new InstantiationException(msg, e); } }
public static <T> T newInstance(Class<T> clazz) { if (clazz == null) { String msg = "Class method parameter cannot be null."; throw new IllegalArgumentException(msg); } try { return clazz.newInstance(); } catch (Exception e) { throw new InstantiationException("Unable to instantiate class [" + clazz.getName() + "]", e); } }
public static <T> T instantiate(Constructor<T> ctor, Object... args) { try { return ctor.newInstance(args); } catch (Exception e) { String msg = "Unable to instantiate instance with constructor [" + ctor + "]"; throw new InstantiationException(msg, e); } }
public static <T> T instantiate(Constructor<T> ctor, Object... args) { try { return ctor.newInstance(args); } catch (Exception e) { String msg = "Unable to instantiate instance with constructor [" + ctor + "]"; throw new InstantiationException(msg, e); } }
public static <T> T newInstance(Class<T> clazz) { if (clazz == null) { String msg = "Class method parameter cannot be null."; throw new IllegalArgumentException(msg); } try { return clazz.newInstance(); } catch (Exception e) { throw new InstantiationException("Unable to instantiate class [" + clazz.getName() + "]", e); } }
public static <T> T newInstance(Class<T> clazz) { if (clazz == null) { String msg = "Class method parameter cannot be null."; throw new IllegalArgumentException(msg); } try { return clazz.newInstance(); } catch (Exception e) { throw new InstantiationException("Unable to instantiate class [" + clazz.getName() + "]", e); } }