--- old/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java 2020-06-23 17:17:21.525931232 +0000 +++ new/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java 2020-06-23 17:17:20.651324793 +0000 @@ -64,6 +64,22 @@ WhiteBox wb = WhiteBox.getWhiteBox(); if (!wb.isClassAlive(CLASS_NAME)) { System.out.println("Class LoadLibraryClass was unloaded"); + while (true) { + try { + System.loadLibrary("LoadLibraryClass"); + // Able to load the library with this class's class loader + // so it must have been unloaded by myLoader. + break; + } catch(java.lang.UnsatisfiedLinkError e) { + if (e.getMessage().contains("already loaded in another classloader")) { + // Library has not been unloaded yet, so wait a little and check again. + Thread.sleep(10); + } else { + throw new RuntimeException( + "Unexpected UnsatisfiedLinkError: " + e.getMessage()); + } + } + } } }