-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Closed
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Andreas Benneke opened SPR-7900 and commented
Annotation driven injection on public methods specified in a non-public base classes does not work, because Java generates bridge methods for the subclass which are not ignored by Spring (as they should IMHO).
Example:
/* not public! */ class Base {
@Resource
public void setResource(Injectable injectable) {
...
}
}
@Component
public class Target extends Base {
}
Same applies to @Autowired
.
The attached maven project demonstrates this.
Workarounds: Use field injection, re-declare the method(s) in the subclass or make the base class public.
Affects: 3.0.5
Attachments:
- injection-test.zip (3.10 kB)
- mylyn-context.zip (4.65 kB)
Issue Links:
- AutowiredAnnotationBeanPostProcessor should ignore bridge methods when looking for annotations [SPR-8434] #13080 AutowiredAnnotationBeanPostProcessor should ignore bridge methods when looking for annotations ("is duplicated by")
- Bridged method detection leads to false positive detection of autowired annotations [SPR-8660] #13302 Bridged method detection leads to false positive detection of autowired annotations
- @Resource injection broken under spring-framework > 4.1.0 [SPR-12490] #17096
@Resource
injection broken under spring-framework > 4.1.0 - Consistent bridge method handling in annotation post-processors [SPR-12495] #17101 Consistent bridge method handling in annotation post-processors
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug