Log error message if CloseNativeLibrary fails
This change adds check for CloseNativeLibrary result and if the
call was unsuccessful logs error message.
Bug: https://issuetracker.google.com/79126103
Test: make
Change-Id: I9280fab7237296c1a06526387aba41f921ffde0f
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc
index fdf0fee..42406cf 100644
--- a/runtime/jni/java_vm_ext.cc
+++ b/runtime/jni/java_vm_ext.cc
@@ -86,7 +86,10 @@
self->GetJniEnv()->DeleteWeakGlobalRef(class_loader_);
}
- android::CloseNativeLibrary(handle_, needs_native_bridge_);
+ std::string error_msg;
+ if (!android::CloseNativeLibrary(handle_, needs_native_bridge_, &error_msg)) {
+ LOG(WARNING) << "Error while unloading native library \"" << path_ << "\": " << error_msg;
+ }
}
jweak GetClassLoader() const {
diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc
index 608f0ee..fc51567 100644
--- a/runtime/ti/agent.cc
+++ b/runtime/ti/agent.cc
@@ -134,7 +134,9 @@
}
if (needs_native_bridge) {
// TODO: Consider support?
- android::CloseNativeLibrary(dlopen_handle, needs_native_bridge);
+ // The result of this call and error_msg is ignored because the most
+ // relevant error is that native bridge is unsupported.
+ android::CloseNativeLibrary(dlopen_handle, needs_native_bridge, error_msg);
*error_msg = StringPrintf("Native-bridge agents unsupported: %s", name_.c_str());
*error = kLoadingError;
return nullptr;