Reflection.java 文件源码

java
阅读 50 收藏 0 点赞 0 评论 0

项目:GameAuthoringEnvironment 作者:
private static boolean typesMatch (Member function, Class<?>[] formals, Object[] actuals) {
    if ((actuals.length == formals.length) ||
        (actuals.length >= formals.length && isVarArgs(function))) {
        int idx = 0;
        // check each parameter individually
        for (; idx < formals.length - 1; idx++) {
            if (!isInstance(formals[idx], actuals[idx])) {
                return false;
            }
        }
        // check each of the last actual args to see if they can be one of varargs
        Class<?> type =
                (formals[idx].isArray()) ? formals[idx].getComponentType() : formals[idx];
        for (; idx < actuals.length; idx++) {
            if (!isInstance(type, actuals[idx])) {
                return false;
            }
        }
        // it was possible, and nothing else returned false, so
        return true;
    }
    // sizes don't match
    return false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号