To use native method libraries, especially when you want to manage multiple versions of a native method library on your iSeries™ server, you need to understand both the Java™ library naming conventions and the library search algorithm.
i5/OS™ uses the first native method library that matches the name of the library that the Java virtual machine (JVM) loads. In order to ensure that i5/OS finds the correct native methods, you must avoid library name clashes and confusion about which native method library the JVM uses.
If the Java code loads a library named Sample, the corresponding executable file must be named either libSample.a or libSample.so.
When you enable i5/OS PASE native methods for the JVM, your server uses three different lists (in the following order) to create a single native method library search path:
In order to perform the search, i5/OS converts the library list to the integrated file system format. QSYS file system objects have equivalent names in the integrated file system, but some integrated file system objects do not have equivalent QSYS file system names. Because the library loader looks for objects in both the QSYS file system and in the integrated file system, i5/OS uses the integrated file system format to search for native method libraries.
The following table shows how i5/OS converts entries in the library list to the integrated file system format:
Library list entry | Integrated file system format |
---|---|
QSYS | /qsys.lib |
QSYS2 | /qsys.lib/qsys2.lib |
QGPL | /qsys.lib/qgpl.lib |
QTEMP | /qsys.lib/qtemp.lib |
Example: Searching for the Sample2 library
In the following example, LIBPATH is set to /home/user1/lib32:/samples/lib32 and PASE_LIBPATH is set to /QOpenSys/samples/lib.
The following table, when read from top to bottom, indicates the full search path:
Source | Integrated file system directories |
---|---|
Library list | /qsys.lib |
LIBPATH | /home/user1/lib32 |
PASE_LIBPATH | /QOpenSys/samples/lib |
In order to search for library Sample2, the Java library loader searches for file candidates in the following order:
i5/OS loads the first candidate in the list that actually exists into the JVM as a native method library. Even though candidates like '/qsys.lib/libSample2.a' and '/qsys.lib/libSample2.so' occur in the search, it is not possible to create integrated file system files or symbolic links in the /qsys.lib directories. Therefore, even though i5/OS checks for these candidate files, it will never find them in integrated file system directories that begin with /qsys.lib.
However, you can create arbitrary symbolic links from other integrated file system directories to i5/OS objects in the QSYS file system. As a result, valid file candidates include files such as /home/user1/lib32/sample2.srvpgm.