title: Which method eventually calls JNI_OnLoad
body: <p>I was trying to figure out how JNI_OnLoad is called internally. I eventually figured out the below tutorial but it does not throw any light on what code part actually calls JNI_OnLoad as an internal function call. Please help me with finding that link function which explicitly calls JNI_OnLoad. i observed that System.loadLibrary calls Runtime which again calls Classloader. But still could not find the native link.</p>
  
  <p>I was especially interested with the one in OnLoad.cpp (android/platform_frameworks_base/blob/master/services/jni/onload.cpp)</p>
  
  <pre><code>JNI_OnLoad
  
  jint JNI_OnLoad(JavaVM *vm, void *reserved);
  
  The VM calls JNI_OnLoad when the native library is loaded (for example, through 
  System.loadLibrary). JNI_OnLoad must return the JNI version needed by the native library.
  In order to use any of the new JNI functions, a native library must export a JNI_OnLoad function that returns JNI_VERSION_1_2. If the native library does not export a JNI_OnLoad function, the VM assumes that the library only requires JNI version JNI_VERSION_1_1. If the VM does not recognize the version number returned by JNI_OnLoad, the native library cannot be loaded.
  </code></pre>
  
  <p><strong>Edit</strong>: My file trace based on  response of @Code Painters is below:</p>
  
  <pre><code>       System.loadLibrary("android_servers");
              |
              |The call System.loadLibrary(name) is effectively equivalent
              |  to the call
              |
              V
          Runtime.getRuntime().loadLibrary(name)
              |
              |public static Runtime getRuntime() {
              |        return currentRuntime;}
              |
              | // Here, also,Classloader.loadlibrary is called, 
              | but this is over-ridden (?)
              | by the Native function of Runtime.java below
              V
          /dalvik/vm/native/java_lang_Runtime.cpp (The jni native
          implementation of Runtime.java):
          /*
           * static String nativeLoad(String filename, ClassLoader loader)
           *
           * Load the specified full path as a dynamic library filled with
           * JNI-compatible methods. Returns null on success, or a failure
           * message on failure.
           */
          static void Dalvik_java_lang_Runtime_nativeLoad{
          //
          success = dvmLoadNativeCode(fileName, classLoader, &amp;reason);
          }
  </code></pre>
  
  <p>I now understand <strong>Runtime.loadlibrary is overloaded with the Dalvik_java_lang_Runtime_nativeLoad native function</strong> and Classloader.loadlibrary is not evoked. Please correct me if I am wrong.</p>