public static <T> T callConstructor(Class<T> klass, Object[] args) {
        Class<?>[] klasses = new Class[args.length];
        for(int i = 0; i < args.length; i++)
            klasses[i] = args[i].getClass();
        return callConstructor(klass, klasses, args);
    }
public static < T > T callConstructor ( Class < T > klass , Object [ ] args ) { Class < ? > [ ] klasses = new Class [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) klasses [ i ] = args [ i ] . getClass ( ) ; return callConstructor ( klass , klasses , args ) ; }
Call the constructor for the given class, inferring the correct types for
the arguments. This could be confusing if there are multiple constructors
with the same number of arguments and the values themselves don't
disambiguate.

@param klass The class to construct
@param args The arguments
@return The constructed value