mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8268129: LibraryLookup::ofDefault leaks symbols from loaded libraries
Reviewed-by: jvernee, psandoz
This commit is contained in:
parent
40c9e258b5
commit
59a539fef1
47 changed files with 730 additions and 725 deletions
|
@ -2432,7 +2432,7 @@ public abstract class ClassLoader {
|
|||
/*
|
||||
* Invoked in the VM class linking code.
|
||||
*/
|
||||
private static long findNative(ClassLoader loader, String entryName) {
|
||||
static long findNative(ClassLoader loader, String entryName) {
|
||||
if (loader == null) {
|
||||
return BootLoader.getNativeLibraries().find(entryName);
|
||||
} else {
|
||||
|
|
|
@ -2393,6 +2393,11 @@ public final class System {
|
|||
public Object classData(Class<?> c) {
|
||||
return c.getClassData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long findNative(ClassLoader loader, String entry) {
|
||||
return ClassLoader.findNative(loader, entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,4 +393,6 @@ public interface JavaLangAccess {
|
|||
* @see java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...)
|
||||
*/
|
||||
Object classData(Class<?> c);
|
||||
|
||||
long findNative(ClassLoader loader, String entry);
|
||||
}
|
||||
|
|
|
@ -385,20 +385,6 @@ public final class NativeLibraries {
|
|||
}
|
||||
}
|
||||
|
||||
public static final NativeLibrary defaultLibrary = new NativeLibraryImpl(Object.class, "<default>", true, true) {
|
||||
|
||||
@Override
|
||||
boolean open() {
|
||||
throw new UnsupportedOperationException("Cannot load default library");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long find(String name) {
|
||||
return NativeLibraries.findEntryInProcess(name);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* The run() method will be invoked when this class loader becomes
|
||||
* phantom reachable to unload the native library.
|
||||
|
@ -479,5 +465,4 @@ public final class NativeLibraries {
|
|||
private static native void unload(String name, boolean isBuiltin, boolean isJNI, long handle);
|
||||
private static native String findBuiltinLib(String name);
|
||||
private static native long findEntry0(NativeLibraryImpl lib, String name);
|
||||
private static native long findEntryInProcess(String name);
|
||||
}
|
||||
|
|
|
@ -246,29 +246,6 @@ Java_jdk_internal_loader_NativeLibraries_findEntry0
|
|||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: jdk_internal_loader_NativeLibraries
|
||||
* Method: findEntryInProcess
|
||||
* Signature: (Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_jdk_internal_loader_NativeLibraries_findEntryInProcess
|
||||
(JNIEnv *env, jclass cls, jstring name)
|
||||
{
|
||||
const char *cname;
|
||||
jlong res;
|
||||
|
||||
if (!initIDs(env))
|
||||
return jlong_zero;
|
||||
|
||||
cname = (*env)->GetStringUTFChars(env, name, 0);
|
||||
if (cname == 0)
|
||||
return jlong_zero;
|
||||
res = ptr_to_jlong(findEntryInProcess(cname));
|
||||
(*env)->ReleaseStringUTFChars(env, name, cname);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: jdk_internal_loader_NativeLibraries
|
||||
* Method: findBuiltinLib
|
||||
|
|
|
@ -333,8 +333,6 @@ JNIEXPORT void InitializeEncoding(JNIEnv *env, const char *name);
|
|||
|
||||
void* getProcessHandle();
|
||||
|
||||
void* findEntryInProcess(const char* name);
|
||||
|
||||
void buildJniFunctionName(const char *sym, const char *cname,
|
||||
char *jniEntryName);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue