Browse Source

Avoid getDeclaredMethod check in ReflectionUtils.isObjectMethod

Closes gh-22730
pull/23050/head
Juergen Hoeller 7 years ago
parent
commit
0cc6a9ef11
  1. 12
      spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

12
spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

@ -558,16 +558,8 @@ public abstract class ReflectionUtils { @@ -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)));
}
/**

Loading…
Cancel
Save