2626 * LoadLibraryUnload class calls ClassLoader.loadedLibrary from multiple threads
2727 */
2828/*
29- * @test
29+ * The driver for this test is LoadLibraryUnloadTest.java.
30+ *
3031 * @bug 8266310
3132 * @summary Loads a native library from multiple class loaders and multiple
3233 * threads. This creates a race for loading the library. The winner
3536 * loaded in a different class loader that won the race. The test
3637 * checks that the loaded class is GC'ed, that means the class loader
3738 * is GC'ed and the native library is unloaded.
38- * @library /test/lib
39- * @build LoadLibraryUnload p.Class1
40- * @run main/othervm/native -Xcheck:jni LoadLibraryUnload
4139 */
4240import jdk .test .lib .Asserts ;
4341import jdk .test .lib .Utils ;
4442
4543import java .lang .*;
44+ import java .lang .ref .Reference ;
4645import java .lang .ref .ReferenceQueue ;
4746import java .lang .reflect .*;
4847import java .lang .ref .WeakReference ;
@@ -161,7 +160,6 @@ public static void main(String[] args) throws Exception {
161160 threads = null ;
162161 canary = null ;
163162 exceptions .clear ();
164-
165163 // Wait for the canary for each of the libraries to be GC'd
166164 // before exiting the test.
167165 for (int i = 0 ; i < LOADER_COUNT ; i ++) {
@@ -172,5 +170,7 @@ public static void main(String[] args) throws Exception {
172170 Asserts .fail ("Too few cleared WeakReferences" );
173171 }
174172 }
173+ // Ensure the WeakReferences are strongly referenced until they can be dequeued
174+ Reference .reachabilityFence (wCanary );
175175 }
176176}
0 commit comments