diff options
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index dedc110b00..b6ba54f2b4 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1211,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 reason; if (!java_vm_->LoadNativeLibrary(env, "libjavacore.so", nullptr, &reason)) { LOG(FATAL) << "LoadNativeLibrary failed for \"libjavacore.so\": " << reason; } } + { + std::string reason; + if (!java_vm_->LoadNativeLibrary(env, "libopenjdk.so", nullptr, &reason)) { + LOG(FATAL) << "LoadNativeLibrary failed for \"libopenjdk.so\": " << reason; + } + } // Initialize well known classes that may invoke runtime native methods. WellKnownClasses::LateInit(env); |