Lightweight finalization for the JDK without any drawbacks was: Why is finalize wrong?
dl at cs.oswego.edu
Sat Aug 9 11:18:54 UTC 2014
> Dne PÃ¡ 8. srpna 2014 15:02:41, Stanimir Simeonoff napsal(a):
> According to articles provided by Andrew, toString() can be on stack,
> even if obj
> (e.g. this for toString()) is garbage collected. This is a bit surprising
> (an OOP fan
> would expect that this is GC root while its instance method is running),
> but such
> behavior is said to be in accordance to the 1.8 spec.
> Question for Doug (as a member of jmm-dev list) then is: would not it be
> wise to
> change the spec to require this to be GC root while its instance method is
Possible changes are being discussed. It is not clear yet
exactly what rules would better match people's expectations
while remaining implementable by JVMs, and/or whether they
would force performance degradations even
for the vast majority of code not using finalizers. It is
very possible the end result will just be to clarify rules and
provide mechanisms allowing better programmer control.
Any changes would go into effect for JDK9 at the earliest,
so if you can find a way to avoid use of finalizers
here, it would be a better option.
More information about the core-libs-dev