Skip to content

Support by-type constructor references in ConstructorOrFactoryMethodResolver #28728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue Jun 29, 2022 · 0 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@mp911de
Copy link
Member

mp911de commented Jun 29, 2022

ConstructorOrFactoryMethodResolver supports type various constructor argument types such as by-name references through inspecting BeanReference. It would be neat to also support RuntimeBeanReference with a Class argument to lookup beans by their type rather than just the type name. Having by-type references that work similar to the non-AOT runtime arrangement would simplify bean definitions.

FWIW, a RuntimeBeanReference leads to the following exception:

Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.data.mongodb.core.mapping.MongoMappingContext' available
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:862)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:691)
	at org.springframework.beans.factory.aot.ConstructorOrFactoryMethodResolver.determineParameterValueType(ConstructorOrFactoryMethodResolver.java:137)
	at org.springframework.beans.factory.aot.ConstructorOrFactoryMethodResolver.determineParameterValueTypes(ConstructorOrFactoryMethodResolver.java:125)
	at org.springframework.beans.factory.aot.ConstructorOrFactoryMethodResolver.resolve(ConstructorOrFactoryMethodResolver.java:84)
	at org.springframework.beans.factory.aot.ConstructorOrFactoryMethodResolver.resolve(ConstructorOrFactoryMethodResolver.java:436)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.<init>(BeanDefinitionMethodGenerator.java:73)
	at org.springframework.beans.factory.aot.BeanDefinitionMethodGeneratorFactory.getBeanDefinitionMethodGenerator(BeanDefinitionMethodGeneratorFactory.java:91)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:44)
	at org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor.processAheadOfTime(BeanRegistrationsAotProcessor.java:32)
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.getContributions(BeanFactoryInitializationAotContributions.java:67)
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:49)
	at org.springframework.context.aot.BeanFactoryInitializationAotContributions.<init>(BeanFactoryInitializationAotContributions.java:44)
	at org.springframework.context.aot.ApplicationContextAotGenerator.generateApplicationContext(ApplicationContextAotGenerator.java:53)
	at org.springframework.boot.AotProcessor.performAotProcessing(AotProcessor.java:150)
	at org.springframework.boot.AotProcessor.process(AotProcessor.java:111)
	at org.springframework.boot.AotProcessor.main(AotProcessor.java:221)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 29, 2022
@jhoeller jhoeller added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 29, 2022
@jhoeller jhoeller self-assigned this Jun 29, 2022
@jhoeller jhoeller added this to the 6.0.0-M5 milestone Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants