Code example for InvocationTargetException

Methods: getCause

0
            constructor.setAccessible(true);
            Object[] resolvedParameters = convertParameters(type, constructor, parameters);
            try { 
                return type.cast(constructor.newInstance(resolvedParameters));
            } catch (InvocationTargetException e) {
                throw e.getCause();
            } 
        } catch (Throwable e) {
            throw new ObjectInstantiationException(type, e);
        } 
    } 
 
    private <T> Object[] convertParameters(Class<T> type, Constructor<?> match, Object[] parameters) {
        Class<?>[] parameterTypes = match.getParameterTypes();
        if (parameterTypes.length < parameters.length) {
            throw new IllegalArgumentException(String.format("Too many parameters provided for constructor for class %s. Expected %s, received %s.", type.getName(), parameterTypes.length, parameters.length));
        } 
        Object[] resolvedParameters = new Object[parameterTypes.length];
        int pos = 0;
        for (int i = 0; i < resolvedParameters.length; i++) {
Connect your IDE to all the code out there  Get Codota for Java