8188052: JNI FindClass needs to specify the class loading context used for library lifecycle hooks

Reviewed-by: alanb, coleenp, dholmes
This commit is contained in:
Mandy Chung 2017-10-10 11:52:42 -07:00
parent 42a29333b9
commit 4c1297b778
8 changed files with 27 additions and 20 deletions

View file

@ -2381,7 +2381,7 @@ public abstract class ClassLoader {
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;
@ -2404,6 +2404,8 @@ public abstract class ClassLoader {
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++) {

View file

@ -1964,6 +1964,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved);
#define JNI_VERSION_1_6 0x00010006
#define JNI_VERSION_1_8 0x00010008
#define JNI_VERSION_9 0x00090000
#define JNI_VERSION_10 0x000a0000
#ifdef __cplusplus
} /* extern "C" */