@@ -138,43 +138,13 @@ static boolean isBridgeMethodFor(Method bridgeMethod, Method candidateMethod, Cl
138
138
return (method != null && isResolvedTypeMatch (method , candidateMethod , declaringClass ));
139
139
}
140
140
141
- /**
142
- * Searches for the generic {@link Method} declaration whose erased signature
143
- * matches that of the supplied bridge method.
144
- * @throws IllegalStateException if the generic declaration cannot be found
145
- */
146
- @ Nullable
147
- private static Method findGenericDeclaration (Method bridgeMethod ) {
148
- // Search parent types for method that has same signature as bridge.
149
- Class <?> superclass = bridgeMethod .getDeclaringClass ().getSuperclass ();
150
- while (superclass != null && Object .class != superclass ) {
151
- Method method = searchForMatch (superclass , bridgeMethod );
152
- if (method != null && !method .isBridge ()) {
153
- return method ;
154
- }
155
- superclass = superclass .getSuperclass ();
156
- }
157
-
158
- // Search interfaces.
159
- Class <?>[] interfaces = ClassUtils .getAllInterfacesForClass (bridgeMethod .getDeclaringClass ());
160
- for (Class <?> ifc : interfaces ) {
161
- Method method = searchForMatch (ifc , bridgeMethod );
162
- if (method != null && !method .isBridge ()) {
163
- return method ;
164
- }
165
- }
166
-
167
- return null ;
168
- }
169
-
170
141
/**
171
142
* Returns {@code true} if the {@link Type} signature of both the supplied
172
143
* {@link Method#getGenericParameterTypes() generic Method} and concrete {@link Method}
173
144
* are equal after resolving all types against the declaringType, otherwise
174
145
* returns {@code false}.
175
146
*/
176
- private static boolean isResolvedTypeMatch (
177
- Method genericMethod , Method candidateMethod , Class <?> declaringClass ) {
147
+ private static boolean isResolvedTypeMatch (Method genericMethod , Method candidateMethod , Class <?> declaringClass ) {
178
148
Type [] genericParameters = genericMethod .getGenericParameterTypes ();
179
149
Class <?>[] candidateParameters = candidateMethod .getParameterTypes ();
180
150
if (genericParameters .length != candidateParameters .length ) {
@@ -197,14 +167,54 @@ private static boolean isResolvedTypeMatch(
197
167
return true ;
198
168
}
199
169
170
+ /**
171
+ * Searches for the generic {@link Method} declaration whose erased signature
172
+ * matches that of the supplied bridge method.
173
+ * @throws IllegalStateException if the generic declaration cannot be found
174
+ */
175
+ @ Nullable
176
+ private static Method findGenericDeclaration (Method bridgeMethod ) {
177
+ // Search parent types for method that has same signature as bridge.
178
+ Class <?> superclass = bridgeMethod .getDeclaringClass ().getSuperclass ();
179
+ while (superclass != null && Object .class != superclass ) {
180
+ Method method = searchForMatch (superclass , bridgeMethod );
181
+ if (method != null && !method .isBridge ()) {
182
+ return method ;
183
+ }
184
+ superclass = superclass .getSuperclass ();
185
+ }
186
+
187
+ Class <?>[] interfaces = ClassUtils .getAllInterfacesForClass (bridgeMethod .getDeclaringClass ());
188
+ return searchInterfaces (interfaces , bridgeMethod );
189
+ }
190
+
191
+ @ Nullable
192
+ private static Method searchInterfaces (Class <?>[] interfaces , Method bridgeMethod ) {
193
+ for (Class <?> ifc : interfaces ) {
194
+ Method method = searchForMatch (ifc , bridgeMethod );
195
+ if (method != null && !method .isBridge ()) {
196
+ return method ;
197
+ }
198
+ else {
199
+ return searchInterfaces (ifc .getInterfaces (), bridgeMethod );
200
+ }
201
+ }
202
+ return null ;
203
+ }
204
+
200
205
/**
201
206
* If the supplied {@link Class} has a declared {@link Method} whose signature matches
202
207
* that of the supplied {@link Method}, then this matching {@link Method} is returned,
203
208
* otherwise {@code null} is returned.
204
209
*/
205
210
@ Nullable
206
211
private static Method searchForMatch (Class <?> type , Method bridgeMethod ) {
207
- return ReflectionUtils .findMethod (type , bridgeMethod .getName (), bridgeMethod .getParameterTypes ());
212
+ try {
213
+ return type .getDeclaredMethod (bridgeMethod .getName (), bridgeMethod .getParameterTypes ());
214
+ }
215
+ catch (NoSuchMethodException ex ) {
216
+ return null ;
217
+ }
208
218
}
209
219
210
220
/**
0 commit comments