Lightweight finalization for the JDK without any drawbacks was: Why is finalize wrong?
Andrew Haley
aph at redhat.com
Fri Aug 8 09:01:14 UTC 2014
On 08/08/14 09:01, Jaroslav Tulach wrote:
> Given the fact that WeakReference & co. has been introduced in JDK
> 1.2 and that version was released at the end of 1998, I bet it was
> just a communication problem, as Andrew must have been talking about
> something else than WeakReference + ReferenceQueue behavior.
You don't have to believe me, read this:
http://thevirtualmachinist.blogspot.co.uk/2011/07/subtle-issue-of-reachability.html
http://thevirtualmachinist.blogspot.co.uk/2011/07/reachability-follow-up.html
The problem is not to do with WeakReferences or ReferenceQueues, but with
the notion of reachability in the VM.
The language which permits this behaviour is:
"Optimizing transformations of a program can be designed that reduce
the number of objects that are reachable to be less than those which
would naively be considered reachable. For example, a Java compiler or
code generator may choose to set a variable or parameter that will no
longer be used to null to cause the storage for such an object to be
potentially reclaimable sooner.
"Another example of this occurs if the values in an object's fields
are stored in registers. The program may then access the registers
instead of the object, and never access the object again. This would
imply that the object is garbage."
Andrew.
More information about the core-libs-dev
mailing list