The test `java/lang/ClassLoader/loadLibraryUnload/LoadLibraryUnloadTest.java` Fails intermittently when expected output from a subprocess is not found.
I suspect a race between the Cleaner that is going to call JNI_OnUnload (in NativeLibraries.java:377) when the ClassLoader is no longer referenced and the test code that exits as soon as it detects that the p.Class1 is no longer referenced. The proposed fix is to create a canary object referenced by the native library and released when the library is unloaded. The Java side of the test provides the canary object and uses a WeakReference to wait for it to be released. When released the child process exits and the driver test will find all of the output it expects. ------------- Commit messages: - 8289919: Failed to unload native library Changes: https://git.openjdk.org/jdk/pull/9474/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9474&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8289919 Stats: 58 lines in 4 files changed: 45 ins; 0 del; 13 mod Patch: https://git.openjdk.org/jdk/pull/9474.diff Fetch: git fetch https://git.openjdk.org/jdk pull/9474/head:pull/9474 PR: https://git.openjdk.org/jdk/pull/9474