Skip to content

Refine ConfigurationPropertiesReflectionHintsProcessor #32186

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
wants to merge 1 commit into from
Closed

Refine ConfigurationPropertiesReflectionHintsProcessor #32186

wants to merge 1 commit into from

Conversation

sdeleuze
Copy link
Contributor

This commit refines ConfigurationPropertiesReflectionHintsProcessor Java bean properties handling in order to register reflection hints only for getters and setters, not for all methods.

It avoids including unconditionally method like SpringApplication#load which in turn avoids shipping BeanDefinitionLoader and related transitively used classes in the native image.

The gain is significant: it allows to remove up to 700 classes (when no XML parser is used elsewhere) and to reduce the memory footprint by 2M of RSS.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 29, 2022
@philwebb
Copy link
Member

Thanks @sdeleuze. Is there any good way to unit test this? The changes look quite subtle and I'm worried we might accidentally revert back at some point and not notice that we've made things worse.

@sdeleuze
Copy link
Contributor Author

Sure, I will update the PR with ConfigurationPropertiesReflectionHintsProcessor unit tests.

@philwebb philwebb added status: on-hold We can't start working on this issue yet type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 29, 2022
@philwebb philwebb added this to the 3.0.x milestone Aug 29, 2022
@@ -158,7 +157,7 @@
* @author Marten Deinum
* @author Nguyen Bao Sach
* @author Chris Bono
* @author Brian Clozel
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate

@sdeleuze
Copy link
Contributor Author

I have pushed a refined commit with proper tests.

This commit refines ConfigurationPropertiesReflectionHintsProcessor
Java bean properties handling in order to register reflection hints
only for getters and setters, not for all methods.

It avoids including unconditionally method like SpringApplication#load
which in turn avoids shipping BeanDefinitionLoader and related transitively
used classes in the native image.

The gain is significant: it allows to remove up to 700 classes
(when no XML parser is used elsewhere) and to reduce the memory footprint
by 2M of RSS.
@sdeleuze
Copy link
Contributor Author

More related to https://github.com/spring-projects/spring-aot-smoke-tests but potentially complementary to the tests provided in this PR : we could use -H:ReportAnalysisForbiddenType=org.springframework.boot.BeanDefinitionLoader native image parameter to fails the native build of let say command-line-runner sample if this class is in the resulting native image (it should not). Once this PR merged, I can submit a PR on smoke tests side to add this.

@bclozel bclozel removed the status: on-hold We can't start working on this issue yet label Sep 1, 2022
@bclozel bclozel modified the milestones: 3.0.x, 3.0.0-M5 Sep 1, 2022
@bclozel bclozel closed this in 138c55e Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants