--- old/src/java.base/share/classes/java/lang/ClassLoader.java 2017-10-04 10:11:06.000000000 -0700 +++ new/src/java.base/share/classes/java/lang/ClassLoader.java 2017-10-04 10:11:05.000000000 -0700 @@ -2369,7 +2369,7 @@ private int jniVersion; // the class from which the library is loaded, also indicates // the loader this native library belongs. - private final Class fromClass; + private Class fromClass; // the canonicalized name of the native library. // or static library name String name; @@ -2392,6 +2392,8 @@ protected void finalize() { synchronized (loadedLibraryNames) { if (fromClass.getClassLoader() != null && loaded) { + this.fromClass = null; // no context when unloaded + /* remove the native library name */ int size = loadedLibraryNames.size(); for (int i = 0; i < size; i++) {