From c1040897cd6d5bc6e76c971035cc36c9d35b31e6 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 27 Jul 2022 14:47:17 +0000 Subject: [PATCH] 8290848: LoadLibraryUnload.java still fails with "Too few cleared WeakReferences" Reviewed-by: mchung, jpai --- test/jdk/ProblemList-Xcomp.txt | 1 - .../loadLibraryUnload/LoadLibraryUnload.java | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/jdk/ProblemList-Xcomp.txt b/test/jdk/ProblemList-Xcomp.txt index 1cd6866c369..fea3e435160 100644 --- a/test/jdk/ProblemList-Xcomp.txt +++ b/test/jdk/ProblemList-Xcomp.txt @@ -29,5 +29,4 @@ java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all java/lang/ref/ReferenceEnqueue.java 8284236 generic-all -java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java 8290848 generic-all java/lang/ProcessBuilder/PipelineLeaksFD.java 8290885 generic-all diff --git a/test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java b/test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java index 95348f295fd..4f48c646fcf 100644 --- a/test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java +++ b/test/jdk/java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnload.java @@ -26,7 +26,8 @@ * LoadLibraryUnload class calls ClassLoader.loadedLibrary from multiple threads */ /* - * @test + * The driver for this test is LoadLibraryUnloadTest.java. + * * @bug 8266310 * @summary Loads a native library from multiple class loaders and multiple * threads. This creates a race for loading the library. The winner @@ -35,14 +36,12 @@ * loaded in a different class loader that won the race. The test * checks that the loaded class is GC'ed, that means the class loader * is GC'ed and the native library is unloaded. - * @library /test/lib - * @build LoadLibraryUnload p.Class1 - * @run main/othervm/native -Xcheck:jni LoadLibraryUnload */ import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import java.lang.*; +import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.reflect.*; import java.lang.ref.WeakReference; @@ -161,7 +160,6 @@ public class LoadLibraryUnload { threads = null; canary = null; exceptions.clear(); - // Wait for the canary for each of the libraries to be GC'd // before exiting the test. for (int i = 0; i < LOADER_COUNT; i++) { @@ -172,5 +170,7 @@ public class LoadLibraryUnload { Asserts.fail("Too few cleared WeakReferences"); } } + // Ensure the WeakReferences are strongly referenced until they can be dequeued + Reference.reachabilityFence(wCanary); } }