Skip to content

Commit 354c3e0

Browse files
committed
Refined exclusion of bridge methods in annotation post-processors (for Java 8 compatibility)
Issue: SPR-12187 (cherry picked from commit 29abca5)
1 parent cc29db4 commit 354c3e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,15 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
391391
}
392392
}
393393
for (Method method : targetClass.getDeclaredMethods()) {
394+
AnnotationAttributes ann = null;
394395
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
395-
AnnotationAttributes ann = BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod) ?
396-
findAutowiredAnnotation(bridgedMethod) : findAutowiredAnnotation(method);
397-
if (ann != null && !method.isBridge() && method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
396+
if (BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod)) {
397+
ann = findAutowiredAnnotation(bridgedMethod);
398+
}
399+
else if (!method.isBridge()) {
400+
ann = findAutowiredAnnotation(method);
401+
}
402+
if (ann != null && method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
398403
if (Modifier.isStatic(method.getModifiers())) {
399404
if (logger.isWarnEnabled()) {
400405
logger.warn("Autowired annotation is not supported on static methods: " + method);

0 commit comments

Comments
 (0)