-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtype: bugA general bugA general bug
Milestone
Description
Bean definitions using RuntimeBeanReference configured with both, a bean name and type, are rendered as RuntimeBeanReference(Class) instead of RuntimeBeanReference(String, Class)
Reproducer:
public class Reproducer implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry,
BeanNameGenerator importBeanNameGenerator) {
registry.registerBeanDefinition("bar1", new RootBeanDefinition(Bar.class));
registry.registerBeanDefinition("bar2", new RootBeanDefinition(Bar.class));
AbstractBeanDefinition foo = BeanDefinitionBuilder.rootBeanDefinition(Foo.class)
.addConstructorArgValue(new RuntimeBeanReference("bar1", Bar.class))
.getBeanDefinition();
registry.registerBeanDefinition("foo", foo);
}
record Foo(Bar bar) {
}
public static class Bar {}
}Generated AOT Bean Definitions:
@Generated
public class Reproducer__BeanDefinitions {
/**
* Bean definitions for {@link Reproducer.Foo}.
*/
@Generated
public static class Foo {
/**
* Get the bean instance supplier for 'foo'.
*/
private static BeanInstanceSupplier<Reproducer.Foo> getFooInstanceSupplier() {
return BeanInstanceSupplier.<Reproducer.Foo>forConstructor(Reproducer.Bar.class)
.withGenerator((registeredBean, args) -> new Reproducer.Foo(args.get(0)));
}
/**
* Get the bean definition for 'foo'.
*/
public static BeanDefinition getFooBeanDefinition() {
RootBeanDefinition beanDefinition = new RootBeanDefinition(Reproducer.Foo.class);
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, new RuntimeBeanReference(Reproducer.Bar.class));
beanDefinition.setInstanceSupplier(getFooInstanceSupplier());
return beanDefinition;
}
}Original report: spring-projects/spring-data-jpa#4105
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtype: bugA general bugA general bug