On Sun, 16 Feb 2020 01:24:43 GMT, Nir Lisker <nlis...@openjdk.org> wrote:
>> I'll be the 2nd reviewer. > >> the referent to the created property object has been garbage collected >> before the `finalize` method is called > > I'm confused. What is that referent exactly and why is it guaranteed to have > been GC'd before finalization? > > the referent to the created property object has been garbage collected > > before the `finalize` method is called > > I'm confused. What is that referent exactly and why is it guaranteed to have > been GC'd before finalization? I meant the referent of the `WeakReference` to the constructed `Property` object on which the `finalize` method is being called. The `asObject` and `xxxxxProperty` methods create a bidirectional binding, which uses weak references to both the original `Property` object and the newly constructed `Property` object. The `finalize` method is on the newly-constructed `Property`. By the time that finalize method is called, the JVM guarantees that no other reference to that `Property` object exists. From the API docs of `Object::finalize`: _The general contract of finalize is that it is invoked if and when the Java™ virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized._ ------------- PR: https://git.openjdk.java.net/jfx/pull/113