Skip to content
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

AOT check on a bean definition with an instance supplier is not consistent #31200

Closed
snicoll opened this issue Sep 11, 2023 · 1 comment
Closed
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Sep 11, 2023

With #29556, We've added a check in BeanDefinitionMethodGenerator to prevent processing a bean definition that has an instance supplier. The check was further refined to look if there is at least one contribution to tune how the registration happens.

The problem is that this check does not validate in any way that the instance supplier is taken care of. The custom code fragments could be about anything really, with the default behavior applying still for generating the code that creates the bean.

We should rather move the check to code fragments that are actually relying on the fact that the BeanDefinition provides the metadata to instantiate the bean, rather than an instance supplier that hides it. These are:

  • getTarget: as the constructorOrFactoryMethod is resolved and that doesn't make sense for a bean that's instantiated by an instance supplier.
  • generateInstanceSupplierCode obviously, as it takes care of generating the code to instantiate the bean.

Moving the check there makes sure that we will not skip cases where we should previously have thrown an exception.

@snicoll snicoll added type: bug A general bug theme: aot An issue related to Ahead-of-time processing labels Sep 11, 2023
@snicoll snicoll added this to the 6.1.0-RC1 milestone Sep 11, 2023
@snicoll snicoll self-assigned this Sep 11, 2023
@snicoll
Copy link
Member Author

snicoll commented Sep 11, 2023

This is visible, in particular, in this test that doesn't provide any customization for the code whatsoever (which means the core container will attempt to resolve the constructor to use and ignore the instance supplier altogether):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant