> Dne Pá 8. srpna 2014 15:02:41, Stanimir Simeonoff napsal(a): > > According to articles provided by Andrew[1], 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 > being > executed? >
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. -Doug