Short circuit ClassUtils.findPubliclyAccessibleMethodIfPossible(...)
Once we find a publicly accessible method, there is no need to continue traversing the type hierarchy. See gh-35556
This commit is contained in:
parent
836634c47f
commit
717358b56b
|
@ -1536,7 +1536,6 @@ public abstract class ClassUtils {
|
||||||
private static Method findPubliclyAccessibleMethodIfPossible(
|
private static Method findPubliclyAccessibleMethodIfPossible(
|
||||||
String methodName, Class<?>[] parameterTypes, Class<?> declaringClass) {
|
String methodName, Class<?>[] parameterTypes, Class<?> declaringClass) {
|
||||||
|
|
||||||
Method result = null;
|
|
||||||
Class<?> current = declaringClass.getSuperclass();
|
Class<?> current = declaringClass.getSuperclass();
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
Method method = getMethodOrNull(current, methodName, parameterTypes);
|
Method method = getMethodOrNull(current, methodName, parameterTypes);
|
||||||
|
@ -1546,11 +1545,11 @@ public abstract class ClassUtils {
|
||||||
if (Modifier.isPublic(method.getDeclaringClass().getModifiers()) &&
|
if (Modifier.isPublic(method.getDeclaringClass().getModifiers()) &&
|
||||||
method.getDeclaringClass().getModule().isExported(
|
method.getDeclaringClass().getModule().isExported(
|
||||||
method.getDeclaringClass().getPackageName(), ClassUtils.class.getModule())) {
|
method.getDeclaringClass().getPackageName(), ClassUtils.class.getModule())) {
|
||||||
result = method;
|
return method;
|
||||||
}
|
}
|
||||||
current = method.getDeclaringClass().getSuperclass();
|
current = method.getDeclaringClass().getSuperclass();
|
||||||
}
|
}
|
||||||
return result;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue