private static Method findCompatibleMethodIfAvailable()

in spark-load/spark-load-common/src/main/java/org/apache/doris/common/jmockit/MethodReflection.java [131:152]


    private static Method findCompatibleMethodIfAvailable(Class<?> theClass, String methodName, Class<?>[] argTypes) {
        if (theClass == null || methodName == null || argTypes == null) {
            throw new IllegalArgumentException();
        }
        Method methodFound = null;

        while (true) {
            Method compatibleMethod = findCompatibleMethodInClass(theClass, methodName, argTypes);
            if (compatibleMethod != null && (methodFound == null ||
                    ParameterReflection.hasMoreSpecificTypes(compatibleMethod.getParameterTypes(),
                            methodFound.getParameterTypes()))) {
                methodFound = compatibleMethod;
            }

            Class<?> superClass = theClass.getSuperclass();
            if (superClass == null || superClass == Object.class) {
                return methodFound;
            }

            theClass = superClass;
        }
    }