RFR: 8305186: Reference.waitForReferenceProcessing should be more accessible to tests

Kim Barrett kbarrett at openjdk.org
Tue Apr 8 22:47:31 UTC 2025


On Tue, 8 Apr 2025 20:20:56 GMT, Brent Christian <bchristi at openjdk.org> wrote:

> Certain specific types of tests involving GC and reference processing need to account for the delay between a GC completing (during which the GC clears a Reference), and the Reference being added to its associated queue. At present, ad hoc mechanisms (with delays/timeout) are used, but can lead to intermittent test failures ([JDK-8298783](https://bugs.openjdk.org/browse/JDK-8298783)  is a recent example).
> 
> A better mechanism already exists in the private `Reference.waitForReferenceProcessing()` method. This PR makes `waitForReferenceProcessing()` available to tests via the `WhiteBox` and `ForceGC` test libraries.

test/lib/jdk/test/lib/util/ForceGC.java line 117:

> 115:      * jtreg tag.
> 116:      *
> 117:      * This method should usually be called after a call to WhiteBox.fullGC().

I suggest waiting until we have a use-case for WFRP _without_ `WB.fullGC` before adding this.
That's because I'm doubtful that such a use-case exists.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24527#discussion_r2034131990


More information about the core-libs-dev mailing list