private static Instantiator getInstantiator(Reflection reflection, Class<?> cls) { try { return new ConstructorInstantiator(cls.getConstructor()); } catch (NoSuchMethodException e) { // Fallback... } try { return reflection.instanceFactory.newInstantiator(cls); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
private static Instantiator getInstantiator(Reflection reflection, Class<?> cls) { try { return new ConstructorInstantiator(cls.getConstructor()); } catch (NoSuchMethodException e) { // Fallback... } try { return reflection.instanceFactory.newInstantiator(cls); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
private static Instantiator getInstantiator(Reflection reflection, Class<?> cls) { try { return new ConstructorInstantiator(cls.getConstructor()); } catch (NoSuchMethodException e) { // Fallback... } try { return reflection.instanceFactory.newInstantiator(cls); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") public <T> T newInstance(Class<T> cls) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException { ClassDescriptor desc = descriptorCache.get(cls); if (desc != null) return (T)desc.newInstance(); try { Constructor<T> constructor = cls.getConstructor(); return constructor.newInstance(); } catch (NoSuchMethodException e) { return (T)instanceFactory.newInstantiator(cls).newInstance(); } }
@SuppressWarnings("unchecked") public <T> T newInstance(Class<T> cls) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException { ClassDescriptor desc = descriptorCache.get(cls); if (desc != null) return (T)desc.newInstance(); try { Constructor<T> constructor = cls.getConstructor(); return constructor.newInstance(); } catch (NoSuchMethodException e) { return (T)instanceFactory.newInstantiator(cls).newInstance(); } }
@SuppressWarnings("unchecked") public <T> T newInstance(Class<T> cls) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException { ClassDescriptor desc = descriptorCache.get(cls); if (desc != null) return (T)desc.newInstance(); try { Constructor<T> constructor = cls.getConstructor(); return constructor.newInstance(); } catch (NoSuchMethodException e) { return (T)instanceFactory.newInstantiator(cls).newInstance(); } }