You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introspect factory method return type for type variable resolution at injection points [SPR-11521] #16146
In Spring Framework 4.0, we take the factory method return type into account for injection targets (i.e. the right-hand side of an assignment) but not for injection points themselves (i.e. the left-hand side). As a consequence, type variables in @Autowired fields or method parameters are not getting resolved if the only place where they are being substituted is the return declaration of the factory method that creates the containing object. See the provided test scenario for #16096 for an example.
We should revisit this for 4.1, introspecting the factory method return type if the containing class itself doesn't substitute the type variable anywhere in its hierarchy.
There are no plans to revisit this issue since there has not been any activity. Arguably, from a Java design perspective, such type variables simply remain unsubstituted in any case. The common solution is to define subclasses that actually substitute the type variables, and then to return those subclasses from the factory methods.
Activity
jhoeller commentedon Jan 8, 2024
There are no plans to revisit this issue since there has not been any activity. Arguably, from a Java design perspective, such type variables simply remain unsubstituted in any case. The common solution is to define subclasses that actually substitute the type variables, and then to return those subclasses from the factory methods.