diff options
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 93ca347b49..c7a5456efb 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -593,6 +593,7 @@ bool Runtime::Start() { PreInitializeNativeBridge("."); } InitNonZygoteOrPostFork(self->GetJniEnv(), + /* is_system_server */ false, NativeBridgeAction::kInitialize, GetInstructionSetString(kRuntimeISA)); } @@ -682,7 +683,8 @@ bool Runtime::InitZygote() { #endif } -void Runtime::InitNonZygoteOrPostFork(JNIEnv* env, NativeBridgeAction action, const char* isa) { +void Runtime::InitNonZygoteOrPostFork( + JNIEnv* env, bool is_system_server, NativeBridgeAction action, const char* isa) { is_zygote_ = false; if (is_native_bridge_loaded_) { @@ -704,7 +706,7 @@ void Runtime::InitNonZygoteOrPostFork(JNIEnv* env, NativeBridgeAction action, co // before fork aren't attributed to an app. heap_->ResetGcPerformanceInfo(); - if (!safe_mode_ && jit_options_->UseJIT() && jit_.get() == nullptr) { + if (!is_system_server && !safe_mode_ && jit_options_->UseJIT() && jit_.get() == nullptr) { // Note that when running ART standalone (not zygote, nor zygote fork), // the jit may have already been created. CreateJit(); @@ -1209,20 +1211,29 @@ void Runtime::InitNativeMethods() { // First set up JniConstants, which is used by both the runtime's built-in native // methods and libcore. JniConstants::init(env); - WellKnownClasses::Init(env); // Then set up the native methods provided by the runtime itself. RegisterRuntimeNativeMethods(env); - // Then set up libcore, which is just a regular JNI library with a regular JNI_OnLoad. - // Most JNI libraries can just use System.loadLibrary, but libcore can't because it's - // the library that implements System.loadLibrary! + // Initialize classes used in JNI. The initialization requires runtime native + // methods to be loaded first. + WellKnownClasses::Init(env); + + // Then set up libjavacore / libopenjdk, which are just a regular JNI libraries with + // a regular JNI_OnLoad. Most JNI libraries can just use System.loadLibrary, but + // libcore can't because it's the library that implements System.loadLibrary! { std::string error_msg; if (!java_vm_->LoadNativeLibrary(env, "libjavacore.so", nullptr, nullptr, nullptr, &error_msg)) { LOG(FATAL) << "LoadNativeLibrary failed for \"libjavacore.so\": " << error_msg; } } + { + std::string error_msg; + if (!java_vm_->LoadNativeLibrary(env, "libopenjdk.so", nullptr, nullptr, nullptr, &error_msg)) { + LOG(FATAL) << "LoadNativeLibrary failed for \"libopenjdk.so\": " << error_msg; + } + } // Initialize well known classes that may invoke runtime native methods. WellKnownClasses::LateInit(env); |