On Thu, 16 Feb 2023 21:41:12 GMT, Sergey Bylokhov <s...@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? For this reason, GC logs are enabled. If, for whatever reason, the call to `System.gc()` is ignored, we'll see it in the test log. Then a specific GC could be selected, for example, or another fix implemented. OOME does not guarantee a full GC cycle either. Having the above in mind, I'd rather keep it simple. ------------- PR: https://git.openjdk.org/jdk/pull/12594