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. ------------- Commit messages: - 8300727: java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java failed with "List wasn't garbage collected" Changes: https://git.openjdk.org/jdk/pull/12594/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12594&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8300727 Stats: 53 lines in 1 file changed: 22 ins; 12 del; 19 mod Patch: https://git.openjdk.org/jdk/pull/12594.diff Fetch: git fetch https://git.openjdk.org/jdk pull/12594/head:pull/12594 PR: https://git.openjdk.org/jdk/pull/12594