On Thu, 8 Sep 2022 20:26:41 GMT, Roger Riggs <rri...@openjdk.org> wrote:
> Modify the LoadLibraryUnload test to call gc() more a few times, allowing > multiple gc cycles to queue the expected refs. > Short the timeout on each cycle to 10 sec. test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java line 171: > 169: dequeueCount++; > 170: } > 171: Asserts.assertEquals(dequeueCount, LOADER_COUNT, "Too few > cleared WeakReferences"); This only invokes GC `LOADER_COUNT` times. I think you may want something like what ForceGC does: int retries = (int)(Math.round(1000L * TIMEOUT_FACTOR) / 200); for (; retries >= 0; retries--) { if (dequeueCount == LOADER_COUNT) return; System.gc(); refQueue.remove(200L); } ------------- PR: https://git.openjdk.org/jdk/pull/10223