in spark-load/spark-load-common/src/main/java/org/apache/doris/common/jmockit/MethodReflection.java [102:125]
private static Method findCompatibleMethodInClass(Class<?> theClass, String methodName, Class<?>[] argTypes) {
if (theClass == null || methodName == null || argTypes == null) {
throw new IllegalArgumentException();
}
Method found = null;
Class<?>[] foundParamTypes = null;
Method[] methods = theClass.getDeclaredMethods();
for (Method declaredMethod : methods) {
if (declaredMethod.getName().equals(methodName)) {
Class<?>[] declaredParamTypes = declaredMethod.getParameterTypes();
int gap = declaredParamTypes.length - argTypes.length;
if (gap == 0 && (ParameterReflection.matchesParameterTypes(declaredParamTypes, argTypes)
|| ParameterReflection.acceptsArgumentTypes(declaredParamTypes, argTypes))
&& (foundParamTypes == null
|| ParameterReflection.hasMoreSpecificTypes(declaredParamTypes, foundParamTypes))) {
found = declaredMethod;
foundParamTypes = declaredParamTypes;
}
}
}
return found;
}