Efficient Java Native Interface for Android Based Mobile Devices
Yann-Hang Lee, Preetham Chandrian, Bo Hu Li · 2011
Java has been making its way into the embedded systems and mobile devices like Android. The Java platform specifies the Java Native Interface (JNΓ) which allows Java code that runs within a JVM to interoperate with applications or libraries that are written in other languages and compiled to the host CPU. JNI plays an important role in embedded system as it provides a mechanism to interact with libraries specific to the platform and to take the advantage of fast execution of native programs. To address the overhead incurred in the JNI due to reflection and serialization, this paper proposes to cache class, field, and method information obtained from reflection for subsequent usage. It also provides a function to pin objects to their memory locations such that they can be accesses through the known reference. The Android emulator is used to evaluate the performance of these techniques and we observed that there was 1030 % performance gain in the Java Native Interface for two Android applications.