On Mon, 9 Sep 2024 16:12:02 GMT, Stuart Marks <sma...@openjdk.org> wrote:

>> The reason for the explicit reference and RF, as I recall, is to guard 
>> against the allocation of the new object being elided entirely, with the 
>> `PhantomReference` constructor being passed null (or itself being elided) 
>> and no reference processing ever actually happening.
>
> @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?)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20898#discussion_r1750564209

Reply via email to