To support loading native code in OSGi bundles, the framework defines a specific header, Bundle-NativeCode, which defines the libraries that are available to the bundle via the System.loadLibrary
call.
The Bundle-NativeCode
header defines one or more native libraries and a clause which states what operating systems and processor architectures are valid for each library. Calls to System.loadLibrary
will then look for libraries mentioned in this list and use only those found for the appropriate architecture. In effect, the Bundle-NativeCode
header replaces the java.library.path
property.
In the prior example, the maths
library was used for performing calculations. In an OSGi bundle, this could be packaged with the bundle itself and referred to via a manifest header:
Bundle-NativeCode: native/maths.dll
When calling System.loadLibrary("maths")
on Windows, the native/maths.dll
library will be automatically extracted to a suitable location on the filesystem and passed...