On Thu, 16 Feb 2023 14:38:21 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> The test has become unstable recently, there were quite a few failures, on 
> Windows mostly. I was lucky enough to find a host where the test failed 
> consistently.
> 
> I call `System.gc()` directly as suggested in comments to the bug. I used 
> `PhantomReference` instead of `WeakReference`.
> 
> Now the test calls `System.gc()` in a loop and waits for the reference to be 
> enqueued. In majority of cases, the test exits the loop at the second attempt.

test/jdk/java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java
 line 72:

> 70:         do {
> 71:             System.out.println("Attempt " + count);
> 72:             System.gc();

As far as I remember the call of System.gc() could be ignored, and the only way 
to trigger GC is to trigger the OOM. Probably we can combine 
referenceQueue.remove(ENQUEUE_TIMEOUT) + OOM?

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

PR: https://git.openjdk.org/jdk/pull/12594

Reply via email to