public static <T> T invokeExactConstructor(final Class<T> cls, Object... args)
            throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
            InstantiationException {
        args = ArrayUtils.nullToEmpty(args);
        final Class<?> parameterTypes[] = ClassUtils.toClass(args);
        return invokeExactConstructor(cls, args, parameterTypes);
    }
public static < T > T invokeExactConstructor ( final Class < T > cls , Object ... args ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException , InstantiationException { args = ArrayUtils . nullToEmpty ( args ) ; final Class < ? > parameterTypes [ ] = ClassUtils . toClass ( args ) ; return invokeExactConstructor ( cls , args , parameterTypes ) ; }
<p>Returns a new instance of the specified class inferring the right constructor
from the types of the arguments.</p>

<p>This locates and calls a constructor.
The constructor signature must match the argument types exactly.</p>

@param <T> the type to be constructed
@param cls the class to be constructed, not {@code null}
@param args the array of arguments, {@code null} treated as empty
@return new instance of {@code cls}, not {@code null}

@throws NullPointerException if {@code cls} is {@code null}
@throws NoSuchMethodException if a matching constructor cannot be found
@throws IllegalAccessException if invocation is not permitted by security
@throws InvocationTargetException if an error occurs on invocation
@throws InstantiationException if an error occurs on instantiation
@see #invokeExactConstructor(java.lang.Class, java.lang.Object[], java.lang.Class[])