leniently fall back to the passed-in method if a bridge method couldn't be resolved (for Groovy 1.7 compatibility)
This commit is contained in:
parent
e10161182b
commit
6c89946d42
|
|
@ -53,7 +53,9 @@ public abstract class BridgeMethodResolver {
|
||||||
* <p>It is safe to call this method passing in a non-bridge {@link Method} instance.
|
* <p>It is safe to call this method passing in a non-bridge {@link Method} instance.
|
||||||
* In such a case, the supplied {@link Method} instance is returned directly to the caller.
|
* In such a case, the supplied {@link Method} instance is returned directly to the caller.
|
||||||
* Callers are <strong>not</strong> required to check for bridging before calling this method.
|
* Callers are <strong>not</strong> required to check for bridging before calling this method.
|
||||||
* @throws IllegalStateException if no bridged {@link Method} can be found
|
* @param bridgeMethod the method to introspect
|
||||||
|
* @return the original method (either the bridged method or the passed-in method
|
||||||
|
* if no more specific one could be found)
|
||||||
*/
|
*/
|
||||||
public static Method findBridgedMethod(Method bridgeMethod) {
|
public static Method findBridgedMethod(Method bridgeMethod) {
|
||||||
if (bridgeMethod == null || !bridgeMethod.isBridge()) {
|
if (bridgeMethod == null || !bridgeMethod.isBridge()) {
|
||||||
|
|
@ -72,12 +74,16 @@ public abstract class BridgeMethodResolver {
|
||||||
return candidateMethods.get(0);
|
return candidateMethods.get(0);
|
||||||
}
|
}
|
||||||
// Search for candidate match.
|
// Search for candidate match.
|
||||||
Method result = searchCandidates(candidateMethods, bridgeMethod);
|
Method bridgedMethod = searchCandidates(candidateMethods, bridgeMethod);
|
||||||
if (result == null) {
|
if (bridgedMethod != null) {
|
||||||
throw new IllegalStateException(
|
// Bridged method found...
|
||||||
"Unable to locate bridged method for bridge method '" + bridgeMethod + "'");
|
return bridgedMethod;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// A bridge method was passed in but we couldn't find the bridged method.
|
||||||
|
// Let's proceed with the passed-in method and hope for the best...
|
||||||
|
return bridgeMethod;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue