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

Stuart Marks smarks at openjdk.org
Fri Apr 11 02:28:37 UTC 2025


On Thu, 10 Apr 2025 22:24:04 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.
>
> Brent Christian has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Separate method to setup Method, per Kim; also simplify exception handling

test/lib/jdk/test/whitebox/WhiteBox.java line 573:

> 571:         wfrp.setAccessible(true);
> 572:         assert wfrp.getReturnType() == Boolean.class;
> 573:         assert wfrp.getParameterCount() == 0;

I don't think this is necessary, as the absence of an array argument to `getDeclaredMethod` should find only methods with zero args.

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

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


More information about the core-libs-dev mailing list