On Fri, 29 Sep 2023 02:56:07 GMT, David Holmes <dhol...@openjdk.org> wrote:
> > > Hmmm okay - it seems fragile to have a psuedo-destructor in release(). > > > > > > I don't know what this comment means. > > Object lifetimes should be well managed such that you can't use an object > after it has been "destroyed". Methods like `release()` effectively nuke the > internals of the object but the object is still available to be (mis)used. > Before this fix `release` left a dangling `_obj` pointer, but that wouldn't > be an issue if the handle itself could not be used after being released. In WeakHandle, it is ok, and in-fact expected, that the wrapped object is null when it is unreachable. This is the reason for the existence of WeakHandle. The contract has always been enforced by the GC Access API. This change additionally clear the field when the object becomes unreachable. ------------- PR Comment: https://git.openjdk.org/jdk/pull/15920#issuecomment-1740741841