static boolean checkArgumentTypesMatchParameterTypes ( boolean isVarArgs , Class < ? > [ ] parameterTypes , Object [ ] arguments ) { if ( parameterTypes == null ) { throw new IllegalArgumentException ( "parameter types cannot be null" ) ; } else if ( ! isVarArgs && arguments . length != parameterTypes . length ) { return false ; } for ( int i = 0 ; i < arguments . length ; i ++ ) { Object argument = arguments [ i ] ; if ( argument == null ) { final int index ; if ( i >= parameterTypes . length ) { index = parameterTypes . length - 1 ; } else { index = i ; } final Class < ? > type = parameterTypes [ index ] ; if ( type . isPrimitive ( ) ) { // Primitives cannot be null return false ; } else { continue ; } } else if ( i >= parameterTypes . length ) { if ( isAssignableFrom ( parameterTypes [ parameterTypes . length - 1 ] , getType ( argument ) ) ) { continue ; } else { return false ; } } else { boolean assignableFrom = isAssignableFrom ( parameterTypes [ i ] , getType ( argument ) ) ; final boolean isClass = parameterTypes [ i ] . equals ( Class . class ) && isClass ( argument ) ; if ( ! assignableFrom && ! isClass ) { return false ; } } } return true ; }
Check argument types match parameter types .