From 1e888706d39fdc2609f0a80ffb3a7bbf833af9a3 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 18 Jan 2013 15:00:23 +0100 Subject: [PATCH] BridgeMethodResolver properly handles bridge methods in interfaces Issue: SPR-9330 --- .../core/BridgeMethodResolver.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 1a67089bf71..1027d4dfc9d 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/org.springframework.core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; @@ -91,7 +90,7 @@ public abstract class BridgeMethodResolver { * Searches for the bridged method in the given candidates. * @param candidateMethods the List of candidate Methods * @param bridgeMethod the bridge method - * @return the bridged method, or null if none found + * @return the bridged method, or {@code null} if none found */ private static Method searchCandidates(List candidateMethods, Method bridgeMethod) { if (candidateMethods.isEmpty()) { @@ -114,7 +113,7 @@ public abstract class BridgeMethodResolver { } /** - * Returns true if the supplied 'candidateMethod' can be + * Returns {@code true} if the supplied '{@code candidateMethod}' can be * consider a validate candidate for the {@link Method} that is {@link Method#isBridge() bridged} * by the supplied {@link Method bridge Method}. This method performs inexpensive * checks and can be used quickly filter for a set of possible matches. @@ -145,7 +144,7 @@ public abstract class BridgeMethodResolver { private static Method findGenericDeclaration(Method bridgeMethod) { // Search parent types for method that has same signature as bridge. Class superclass = bridgeMethod.getDeclaringClass().getSuperclass(); - while (!Object.class.equals(superclass)) { + while (superclass != null && !Object.class.equals(superclass)) { Method method = searchForMatch(superclass, bridgeMethod); if (method != null && !method.isBridge()) { return method; @@ -166,10 +165,10 @@ public abstract class BridgeMethodResolver { } /** - * Returns true if the {@link Type} signature of both the supplied + * Returns {@code true} if the {@link Type} signature of both the supplied * {@link Method#getGenericParameterTypes() generic Method} and concrete {@link Method} * are equal after resolving all {@link TypeVariable TypeVariables} using the supplied - * TypeVariable Map, otherwise returns false. + * TypeVariable Map, otherwise returns {@code false}. */ private static boolean isResolvedTypeMatch( Method genericMethod, Method candidateMethod, Map typeVariableMap) { @@ -205,7 +204,7 @@ public abstract class BridgeMethodResolver { /** * If the supplied {@link Class} has a declared {@link Method} whose signature matches * that of the supplied {@link Method}, then this matching {@link Method} is returned, - * otherwise null is returned. + * otherwise {@code null} is returned. */ private static Method searchForMatch(Class type, Method bridgeMethod) { return ReflectionUtils.findMethod(type, bridgeMethod.getName(), bridgeMethod.getParameterTypes()); @@ -219,8 +218,6 @@ public abstract class BridgeMethodResolver { * @return whether signatures match as described */ public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method bridgedMethod) { - Assert.isTrue(bridgeMethod != null); - Assert.isTrue(bridgedMethod != null); if (bridgeMethod == bridgedMethod) { return true; }