<https://www.jetbrains.com/help/inspectopedia/Inne...
# random
a
https://www.jetbrains.com/help/inspectopedia/InnerClassMayBeStatic.html > A
static
inner class does not keep an implicit reference to its enclosing instance. When using Java 17 or before, this prevents a common cause of memory leaks and uses less memory per instance of the class. Did something change in Java 18+ to make static non-static inner classes less vulnerable?
r
You mean "to make non-static inner classes less vulnerable"?
fixedtape 1
🙏 1
h
AFAIK in Java 18
javac
got smarter and only creates the reference to the enclosing instance when the outer instance is actually used from the inner class: https://www.oracle.com/java/technologies/javase/18-relnote-issues.html#JDK-8271623
gratitude thank you 1