RFR: 8339687: Rearrange reachabilityFence()s in jdk.test.lib.util.ForceGC

Stuart Marks smarks at openjdk.org
Mon Sep 9 16:28:06 UTC 2024


On Mon, 9 Sep 2024 16:12:02 GMT, Stuart Marks <smarks at 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


More information about the core-libs-dev mailing list