JNI Native Bindings

Mon Jun 20 2016

Java Native Interfaces is the mechanism in which native C/C++ functions can be called as native methods in Java. It is the bridge between Java and C++.

This part of the development process tends to be challenging. Debugging this area of the code is error-prone, and good JNI documentation and best practices are a bit lacking. Also, I've seen some pretty massive, monolithic JNI bridges that are many thousands of lines of code in a single file. Needless to say, one must be mindful to get this part right!

The code pertaining to the JNI bridge in Tangram is here:



Android Bridge Relationship

Java Bridge C++
MapController.java jniExports.cpp platform_android.cpp

Native Java Methods

All of the native methods JNI binds to are in MapController.java. The actual binding is in jniExports.cpp, and the JNI setup is in platform_android.cpp.

Calling Java methods from C++

There are several places that Java methods are called from C++. All of this happens in platform_android.cpp. Likewise, all of the Java methods that are called are in MapController.java.

results matching ""

    No results matching ""