Avoid getDeclaredMethod check in ReflectionUtils.isObjectMethod

Closes gh-22730
This commit is contained in:
Juergen Hoeller
2019-04-03 18:21:26 +02:00
parent 9ea02c6dfa
commit 0cc6a9ef11

View File

@@ -558,16 +558,8 @@ public abstract class ReflectionUtils {
* Determine whether the given method is originally declared by {@link java.lang.Object}.
*/
public static boolean isObjectMethod(@Nullable Method method) {
if (method == null) {
return false;
}
try {
Object.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
return true;
}
catch (Exception ex) {
return false;
}
return (method != null && (method.getDeclaringClass() == Object.class ||
isEqualsMethod(method) || isHashCodeMethod(method) || isToStringMethod(method)));
}
/**