Skip to content

Use BeanInstanceSupplier with matching arguments#36949

Open
yeomin4242 wants to merge 1 commit into
spring-projects:mainfrom
yeomin4242:feat/gh-36649-aot-prototype-autowiring-main
Open

Use BeanInstanceSupplier with matching arguments#36949
yeomin4242 wants to merge 1 commit into
spring-projects:mainfrom
yeomin4242:feat/gh-36649-aot-prototype-autowiring-main

Conversation

@yeomin4242

Copy link
Copy Markdown
Contributor

BeanFactory#getBean(..., args) currently skips an InstanceSupplier whenever explicit arguments are provided. In AOT/native mode this can make a prototype bean with runtime constructor arguments use a different instantiation path, so AOT-generated post-processing such as field autowiring is not applied.

This PR lets BeanInstanceSupplier opt in when the explicit arguments match the AOT-selected constructor or factory method. Other cases continue through the regular bean factory path, preserving dynamic constructor resolution for argument shapes that cannot be handled safely by the generated supplier.

Regression tests cover the original prototype bean scenario with field autowiring, explicit argument handling in BeanInstanceSupplier, and fallback behavior for unsupported argument shapes.

Closes gh-36649

BeanFactory#getBean(..., args) previously skipped instance suppliers whenever explicit arguments were provided. In AOT/native mode, this could make a prototype bean with runtime constructor arguments use a different instantiation path and miss generated post-processing.

Allow BeanInstanceSupplier to opt in when the explicit arguments exactly match the selected constructor or factory method, while keeping the regular bean factory path for other argument shapes.

Closes spring-projectsgh-36649

Signed-off-by: YeongJae Min <whereismysejong@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 19, 2026
@yeomin4242 yeomin4242 marked this pull request as ready for review June 19, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autowiring not working for native applications with prototype components

2 participants