From 0cc6a9ef11b93d1d37899f0fbfb6ab57abfbde6a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 3 Apr 2019 18:21:26 +0200 Subject: [PATCH] Avoid getDeclaredMethod check in ReflectionUtils.isObjectMethod Closes gh-22730 --- .../org/springframework/util/ReflectionUtils.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 4c3475b6912..8b038d726a6 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -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))); } /**