Skip to content

Introspect factory method return type for type variable resolution at injection points [SPR-11521] #16146

Closed as not planned

Description

@spring-projects-issues

Juergen Hoeller opened SPR-11521 and commented

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.


Affects: 4.0.2

Issue Links:

Activity

  1. added
    in: core
    on Jul 26, 2021
  2. jhoeller commented on Jan 8, 2024

    @jhoeller
    Contributor

    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.

  3. removed this from the 6.x Backlog milestone on Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coretype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions