On Tue, 8 Apr 2025 21:19:06 GMT, Roger Riggs <rri...@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/whitebox/WhiteBox.java line 569:
> 
>> 567:    * This method should usually be called after a call to 
>> WhiteBox.fullGC().
>> 568:    */
>> 569:   public static void waitForReferenceProcessing() {
> 
> Can the code duplication be avoided?

That would be nice.
A primary goal here is to not disrupt existing tests that use `WhiteBox` or 
`ForceGC`, (e.g. by necessitating additional tags, `@run` arguments, etc).
I don't think there's a way for `WhiteBox.java` and `ForceGC.java` to both 
refer to code at some shared location without tests having to add a new tag - 
`@build`, I think.
However I will look into it a bit further.

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

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

Reply via email to