On Mon, 9 Sep 2024 16:25:15 GMT, Stuart Marks <sma...@openjdk.org> wrote:
>> @dholmes-ora Is this really possible? The `obj` ref is passed to the >> PhantomReference constructor, which stores it in a field, the constructed >> PhantomReference is returned, and it's then used in a reachabilityFence call >> below. So `obj` should remain reachable the entire time, right? > > (As an aside, I wasn't able to determine what any of the Reference classes do > if they're created with a null reference. Possibly a spec bug?) @stuart-marks My recollection, which I can't confirm is that this pattern was discussed internally and there was a lot of uncertainty about what was actually needed. Interestingly there was zero discussion of this in the actual PR that added it - https://github.com/openjdk/jdk/pull/8979 Thinking it through now, I tend to agree with you that the RF for `ref` suffices to prevent `obj` from being elided ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20898#discussion_r1751000575