public static Constructor findConstructor ( Class < ? > type , Object [ ] args ) { outer : for ( Constructor constructor : type . getConstructors ( ) ) { Class < ? > [ ] paramTypes = constructor . getParameterTypes ( ) ; if ( paramTypes . length != args . length ) continue ; for ( int i = 0 ; i < args . length ; i ++ ) { Object arg = args [ i ] ; if ( arg != null && ! paramTypes [ i ] . isAssignableFrom ( arg . getClass ( ) ) && ! isBoxedType ( paramTypes [ i ] , arg . getClass ( ) ) ) continue outer ; if ( arg == null && paramTypes [ i ] . isPrimitive ( ) ) continue outer ; } return constructor ; } throw new GrammarException ( "No constructor found for %s and the given %s arguments" , type , args . length ) ; }
Finds the constructor of the given class that is compatible with the given arguments .