RFR: 8271623: Omit enclosing instance fields from inner classes that don't use it
Liam Miller-Cushon
cushon at google.com
Fri Nov 12 18:32:07 UTC 2021
Hello,
Is anyone from the compiler group interested in reviewing the fix for
JDK-8271623?
There was some previous discussion about the change on amber-spec-experts
[1][2], I should have added compiler-dev@ sooner.
The idea is to omit the synthetic field that holds a reference to the
enclosing instance of an inner class if the inner class doesn't capture any
state from its enclosing instance. This avoids a potential memory leak, and
reduces the footprint of the inner class.
The optimization is currently implemented by adding logic to Lower to track
whether the symbol for the enclosing instance field is actually used when
generating code for the inner class, and generating the declaration and
initialization of the field only if it is used.
[1]
https://mail.openjdk.java.net/pipermail/amber-spec-experts/2021-July/003061.html
[2]
https://mail.openjdk.java.net/pipermail/amber-spec-experts/2021-August/003064.html
review: https://git.openjdk.java.net/jdk/pull/4966
bug: https://bugs.openjdk.java.net/browse/JDK-8271623
CSR: https://bugs.openjdk.java.net/browse/JDK-8271717
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20211112/5af216b4/attachment.htm>
More information about the compiler-dev
mailing list