Initialize native loader before starting runtime
Loading public libraries before everything else
to prevent situation when libssl.so gets into
libopenjdk.so load group which then prevented
from unloading by a global library referencing
the very same libssl.so
Bug: http://b/28449304
Change-Id: I3bbff3cc6926c2377ae5cb5b7b5b5d6e26ea4470
(cherry picked from commit c544f34bfed4273b38e5c3769c627e0c3e9c5d73)
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index 79c3203..d983a9f 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -943,6 +943,11 @@
if (!Runtime::Create(options, ignore_unrecognized)) {
return JNI_ERR;
}
+
+ // Initialize native loader. This step makes sure we have
+ // everything set up before we start using JNI.
+ android::InitializeNativeLoader();
+
Runtime* runtime = Runtime::Current();
bool started = runtime->Start();
if (!started) {
@@ -952,10 +957,6 @@
return JNI_ERR;
}
- // Initialize native loader. This step makes sure we have
- // everything set up before we start using JNI.
- android::InitializeNativeLoader();
-
*p_env = Thread::Current()->GetJniEnv();
*p_vm = runtime->GetJavaVM();
return JNI_OK;