public static <T> Constructor<T> findConstructor(Class<T> cls, Class<?>... argTypes)
            throws NoSuchMethodException {
        Constructor<T> ctor;
        try {
            ctor = cls.getDeclaredConstructor(argTypes);
        } catch (NoSuchMethodException e) {
            throw e;
        } catch (Exception e) {
            throw new IllegalArgumentException("Unable to find constructor of class " + cls.getName() +
                    ", problem: " + e.getMessage(), ExceptionUtils.getRootCause(e));
        }
        // must be public
        if (!Modifier.isPublic(ctor.getModifiers())) {
            throw new IllegalArgumentException("Constructor for " + cls.getName() +
                    " is not accessible (non-public?): not allowed to try modify access via Reflection: can not instantiate type");
        }
        return ctor;
    }
public static < T > Constructor < T > findConstructor ( Class < T > cls , Class < ? > ... argTypes ) throws NoSuchMethodException { Constructor < T > ctor ; try { ctor = cls . getDeclaredConstructor ( argTypes ) ; } catch ( NoSuchMethodException e ) { throw e ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Unable to find constructor of class " + cls . getName ( ) + ", problem: " + e . getMessage ( ) , ExceptionUtils . getRootCause ( e ) ) ; } if ( ! Modifier . isPublic ( ctor . getModifiers ( ) ) ) { throw new IllegalArgumentException ( "Constructor for " + cls . getName ( ) + " is not accessible (non-public?): not allowed to try modify access via Reflection: can not instantiate type" ) ; } return ctor ; }
Obtain an accessible constructor for the given class and parameters.

@param cls the class to check
@param argTypes the argument types of the desired constructor
@param <T> the generic type
@return the constructor reference
@throws NoSuchMethodException if no such constructor exists