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

__BeanFactoryRegistrations generated file can be too large with a BeanFactory with lots of bean definitions #33126

Closed
dreamlike-ocean opened this issue Jun 30, 2024 · 2 comments
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

@dreamlike-ocean
Copy link

I have a Spring Boot project with roughly 10k beans. When I use the spring-boot process-aot plugin, the generated code is rejected by javac with the error message Code too large /home/dreamlike/javaCode/leydenPlayground/leyden-spring/target/spring-aot/main/sources/io/github/dreamlike/LeydenSpringMain__BeanFactoryRegistrations.java 10049:15
(this file has about 20k lines).

I’m wondering if this plugin allows for the creation of multiple BeanFactoryRegistration files to avoid this issue? The specific reproduction code can be found in this repository
https://github.com/dreamlike-ocean/leydenPlayground

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 30, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Jul 1, 2024
@bclozel bclozel added in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing labels Jul 1, 2024
@snicoll snicoll self-assigned this Jul 1, 2024
@snicoll snicoll changed the title Compilation Failure of Code Generated by spring-boot process-aot Plugin __BeanFactoryRegistrations generated file can be too large with a BeanFactory with lots of bean definitions Jul 1, 2024
@snicoll
Copy link
Member

snicoll commented Jul 1, 2024

Thanks for the report. This was bound to happen since we're generating one line per bean definitions in that file. Fortunately, thanks to the help of @philwebb, this problem is largely reduced due to us using isolated generated classes for the bean definitions themselves. We may be pragmatic about this particular file, as I am not sure we can fix this in a generic fashion.

@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 1, 2024
@snicoll snicoll modified the milestones: 6.1.x, 6.2.x Jul 1, 2024
@snicoll snicoll modified the milestones: 6.2.x, 6.2.0-M6 Jul 17, 2024
@snicoll
Copy link
Member

snicoll commented Jul 17, 2024

For the record the size of the file isn't the problem, a size limit on methods is. To fix this, we now slice bean registrations per 1000 bean definitions in isolated methods. The number is a bit arbitrary so perhaps we'll have to adapt somehow but that looks good enough for a start. And your sample now works with 6.2.0-SNAPSHOT.

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

4 participants