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

Make inner classes static when feasible #28433

Closed
wants to merge 3 commits into from
Closed

Make inner classes static when feasible #28433

wants to merge 3 commits into from

Conversation

missingdays
Copy link
Contributor

@missingdays missingdays commented May 9, 2022

A static nested class does not keep an implicit reference to its enclosing instance.

This prevents a common cause of memory leaks and uses less memory per instance of the class.

A static inner class does not keep an implicit reference to its enclosing instance.
This prevents a common cause of memory leaks and uses less memory per instance of the class.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 9, 2022
@sbrannen sbrannen self-assigned this May 10, 2022
@sbrannen sbrannen changed the title Make inner classes static when it's possible and makes sense Make inner classes static when feasible May 10, 2022
@sbrannen sbrannen added type: task A general task in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 10, 2022
@sbrannen sbrannen added this to the 5.3.20 milestone May 10, 2022
sbrannen added a commit that referenced this pull request May 10, 2022
@jhoeller
Copy link
Contributor

Half of the sources affected only show up in main, so this PR seems more like a 6.0 M4 candidate. Maybe we could manually backport a few of the inner class definitions as they exist in 5.3.x, @sbrannen ?

@sbrannen
Copy link
Member

I've already merged it locally for 5.3.x (excluding nonexistent classes) and main.

@jhoeller
Copy link
Contributor

Sounds good, it's definitely worth having in both branches for everything affected. There were just quite a few new AOT code spots in that PR, not too many spots that affect 5.3.x as well. We generally strive for static inner classes where possible already.

sbrannen pushed a commit to sbrannen/spring-framework that referenced this pull request May 10, 2022
A static nested class does not keep an implicit reference to its
enclosing instance.

This prevents a common cause of memory leaks and uses less memory per
instance of the class.

Closes spring-projectsgh-28433
@sbrannen sbrannen closed this in 941b92c May 10, 2022
@sbrannen
Copy link
Member

This has been merged into 5.3.x (selectively) and main.

Thanks

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) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants