-
Notifications
You must be signed in to change notification settings - Fork 354
Add suport for ManagedList and ManagedSet #1483
Comments
@abuijze thanks for the report and the sample. AOT doesn't support |
@abuijze if you have the cycles to give Spring Native |
The generated AOT file now generates a compiler error (on OpenJDK 11.0.12)
|
fyi, the code it generates is: BeanDefinitionRegistrar.of("MessageHandlerConfigurer$$Axon$$COMMAND", MessageHandlerConfigurer.class).withConstructor(MessageHandlerConfigurer.Type.class, List.class)
.instanceSupplier((instanceContext) -> instanceContext.create(beanFactory, (attributes) -> new MessageHandlerConfigurer(attributes.get(0), attributes.get(1)))).customize((bd) -> {
ConstructorArgumentValues argumentValues = bd.getConstructorArgumentValues();
argumentValues.addIndexedArgumentValue(0, "COMMAND");
argumentValues.addIndexedArgumentValue(1, Stream.of(new RuntimeBeanReference("myCommandHandler")).collect(Collectors.toCollection(ManagedList::new)));
}).register(beanFactory); Which looks correct to me... |
Ah damn. That works on Java 17 but not 11 I suspect. |
Running it on OpenJDK 17.0.2 gives me the same compiler error. |
🤦 |
The code is correct but the compiler is unable to infer the type unless the value is assigned unfortunately. This is due to the overloaded |
The |
What if you explicitly use the |
Nope. There are many other places where such an inference can go wrong. That code is generic and not specific to this particular feature. |
In one of my beans, I rely on a list of other bean instances to be injected. The items in the list can be of any type, so it's practically defined as a
List<Object>
.A
BeanDefinitionRegistryPostProcessor
generates theBeanDefinition
for that bean. I use aManageList
containingRuntimeBeanNameReference
s (but tried other BeanReference implementations too) to refer to the beans that I need to be injected.Without Spring AOT, this works perfectly. The injected value is indeed a list of actual bean instances.
When running Spring AOT, however, the injected value is a
List
ofRuntimeBeanNameReference
.In the
ContextBootstrapInitializer
, the AOT plugin generates the following code for the bean:The relevant part:
When I change that manually to
Everything works as expected.
Do I need to configure something differently, or should the generated
ContextBootstrapInitializer
use a ManageList as a container for collections that contain a BeanReference?The text was updated successfully, but these errors were encountered: