Description
nebhale opened SPR-11004 and commented
Note that this applies to the current 4.0 snapshots, not the actual RC1 release.
Currently autowiring a bean of a type that could have a generic declaration but doesn't (e.g. List
instead of List<String>
) does not work when that bean should be autowired to a type that has the generic declaration (e.g. List<String>
). And example is that the following wiring would not work:
@Bean
List list() {
return new ArrayList();
}
@Bean
Object listConsumer(List<String> list) {
return list;
}
This is useful in cases where a framework (saw spring-data-jpa) automatically creates a type (say PagedResourcesAssembler) that could be generified, but isn't. Then a consumer attempts to autowire that type, but with the generics (to quiet the compiler) and cannot get a wiring.
I've attached a test case that replicates the issue. Simply run mvm clean package && java -jar target/test.jar
.
Affects: 4.0 RC1
Reference URL: f29092d#commitcomment-4368780
Attachments:
- test.zip (1.63 kB)
- test-2.zip (1.99 kB)
Issue Links:
- Generic autowiring should support wiring of components with unresolved type variables [SPR-10993] #15621 Generic autowiring should support wiring of components with unresolved type variables
- NPE in ResolvableType.hasUnresolvableGenerics [SPR-11034] #15662 NPE in ResolvableType.hasUnresolvableGenerics
- DATACMNS-388 Improve generics declaration in HateoasAwareSpringDataWebConfiguration