Loading a native library

Once Native Bridge is ready to use, we can have a look at what happens when an application loads a native library in a different processor architecture.

We know that, if we implement a native method in a shared library, we need to implement a JNI_OnLoad entry point, which is used to register native methods. The Java code needs to make a call to either System.load or System.loadLibrary to load this shared library. In the following table, it is the call stack from System.loadLibrary to JNI_OnLoad:

Function

Class

Language

System.loadLibrary

Runtime

Java

doLoad

Runtime

Java

nativeLoad

Runtime

JNI

Runtime_nativeLoad

Runtime

C++

LoadNativeLibrary

JavaVMExt

C++

JNI_OnLoad ...

Get Android System Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.