use of org.gradle.internal.reflect.ObjectInstantiationException in project gradle by gradle.
the class DependencyInjectingInstantiator method newInstance.
public <T> T newInstance(Class<? extends T> type, Object... parameters) {
try {
CachedConstructor cached = cachedConstructors.get(type);
if (cached.error != null) {
throw cached.error;
}
Constructor<?> constructor = cached.constructor;
Object[] resolvedParameters = convertParameters(type, constructor, parameters);
try {
Object instance = constructor.newInstance(resolvedParameters);
if (instance instanceof WithServiceRegistry) {
((WithServiceRegistry) instance).setServices(services);
}
return type.cast(instance);
} catch (InvocationTargetException e) {
throw e.getCause();
}
} catch (Throwable e) {
throw new ObjectInstantiationException(type, e);
}
}
Aggregations