Switch init order of WellKnownClasses and NativeMethods
Native methods need to be loaded before initializing java.lang.Thread
class, make sure we do that first.
Bug: 25760806
(cherry picked from commit 321f0cdf07e09335cad13a96de35c28795880535)
Change-Id: I5f3f7819f660f9ce472a96a13201ab09950e92e3
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 39d71b8..b175d6b 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1199,11 +1199,14 @@
// 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);
+ // 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!