Effective Foreign Function Interfaces: From JNI to JNR
JavaOne 2013 CON4767
Ryan A. Sciampacone, Senior Software Developer, IBM JTC
What do you do when your application needs access to platform features that aren’t available in the Java platform? You need a foreign function interface (FFI). The Java Native Interface (JNI) is the classic power tool for calling native code from your Java program. Using JNI means stepping out of the managed safety of the JVM into the wilds of native code. This session explains the most common JNI performance and correctness pitfalls and explains how to find and avoid them. As the JVM becomes the runtime of choice for more languages, the FFI landscape is also evolving. This session introduces alternative FFI approaches that minimizes effort (SWIG) and native code. It examines JNR in detail and shows how alternatives perform relative to handwritten JNI.