OSGi has support for loading native code in an application, which may be used to provide access to platform-specific functionality or for performance reasons. This chapter will present an overview of the Java Native Interface, and then cover how native code can be bundled in with plug-ins. It will also cover how fragment bundles can provide extensions to bundles in an OSGi runtime, such as native code libraries and Java patches.
The Java Native Interface (JNI) is a standard way in which any Java program can interact with native code. The process for working with native code can be summarized as follows: