summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2016-05-05 08:02:17 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2016-05-05 08:02:17 +0000
commit0cf0dbd5f8ae5a1ccd51b45c4d692eedb3ff8a2b (patch)
tree58b1b9651f595efe772db7b61351bfd971699306
parent2eb3ba9fcc120b74bdf9f61342347379223973f3 (diff)
Revert "(dl)Close native libraries on unload"
Failures on test 136. Bug: http://b/28406866 This reverts commit 2eb3ba9fcc120b74bdf9f61342347379223973f3. Change-Id: Ic70aceb0831256b1e12730e5508e86e6fed8cb42
-rw-r--r--runtime/java_vm_ext.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index eebcc689c9..35bb3c3301 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -74,10 +74,6 @@ class SharedLibrary {
if (self != nullptr) {
self->GetJniEnv()->DeleteWeakGlobalRef(class_loader_);
}
-
- if (!needs_native_bridge_) {
- android::CloseNativeLibrary(handle_);
- }
}
jweak GetClassLoader() const {
@@ -275,7 +271,8 @@ class Libraries {
REQUIRES(!Locks::jni_libraries_lock_)
SHARED_REQUIRES(Locks::mutator_lock_) {
ScopedObjectAccessUnchecked soa(Thread::Current());
- std::vector<SharedLibrary*> unload_libraries;
+ typedef void (*JNI_OnUnloadFn)(JavaVM*, void*);
+ std::vector<JNI_OnUnloadFn> unload_functions;
{
MutexLock mu(soa.Self(), *Locks::jni_libraries_lock_);
for (auto it = libraries_.begin(); it != libraries_.end(); ) {
@@ -286,7 +283,15 @@ class Libraries {
// the native libraries of the boot class loader.
if (class_loader != nullptr &&
soa.Self()->IsJWeakCleared(class_loader)) {
- unload_libraries.push_back(library);
+ void* const sym = library->FindSymbol("JNI_OnUnload", nullptr);
+ if (sym == nullptr) {
+ VLOG(jni) << "[No JNI_OnUnload found in \"" << library->GetPath() << "\"]";
+ } else {
+ VLOG(jni) << "[JNI_OnUnload found for \"" << library->GetPath() << "\"]";
+ JNI_OnUnloadFn jni_on_unload = reinterpret_cast<JNI_OnUnloadFn>(sym);
+ unload_functions.push_back(jni_on_unload);
+ }
+ delete library;
it = libraries_.erase(it);
} else {
++it;
@@ -294,17 +299,9 @@ class Libraries {
}
}
// Do this without holding the jni libraries lock to prevent possible deadlocks.
- typedef void (*JNI_OnUnloadFn)(JavaVM*, void*);
- for (auto library : unload_libraries) {
- void* const sym = library->FindSymbol("JNI_OnUnload", nullptr);
- if (sym == nullptr) {
- VLOG(jni) << "[No JNI_OnUnload found in \"" << library->GetPath() << "\"]";
- } else {
- VLOG(jni) << "[JNI_OnUnload found for \"" << library->GetPath() << "\"]: Calling...";
- JNI_OnUnloadFn jni_on_unload = reinterpret_cast<JNI_OnUnloadFn>(sym);
- jni_on_unload(soa.Vm(), nullptr);
- }
- delete library;
+ for (JNI_OnUnloadFn fn : unload_functions) {
+ VLOG(jni) << "Calling JNI_OnUnload";
+ (*fn)(soa.Vm(), nullptr);
}
}