Java native interface (JNI)

The Oracle Java Native Interface (JNI) standard defines the C language APIs that enable Java routines to call C and C++ routines. JNI defines the way that these routines can start and interact with a Java Virtual Machine (JVM). It also allows you to load the JVM into native applications to integrate Java functionality with native applications.

NSJ 11 supports JNI and Invocation API with the following modifications:

  • Set the _RLD_LIB_PATH environment variable to point to the User DLL location.

    export _RLD_LIB_PATH=dll-path[:dll_pathn]...

    where, dll-path and dll-pathn are the User DLL directories.

    For example, if the user DLLs are in the directory /home/mydll

    export _RLD_LIB_PATH=/home/mydll

  • NSJ 11 supports only the POSIX User Thread library (PUT). As a result of this, additional migration considerations arise while migrating threaded native code to NSJ 11. There are two kinds of native applications that require changes:

    1. Applications that dynamically load libjvm.so and invoke JVM using Invocation APIs. For more information, see Calling Java methods from C or C++.

    2. Applications that use Pthread library to create multi-threaded application. For more information, see Threading considerations for native code.

  • If native C or C++ routines invoke Transaction Management Facility (TMF) calls, you must use TMF transaction jacket routines defined in “TMF Transaction Jacket Routines” in the “Using the POSIX User Thread (PUT) Model Library” section in the Open System Services Programmer's Guide.

    The calls are:

    • PUT_ABORTTRANSACTION()
    • PUT_BEGINTRANSACTION()
    • PUT_ENDTRANSACTION()
    • PUT_RESUMETRANSACTION()

    OSS supports a maximum of 1000 concurrent transactions in a process. However, JVM is an exception where the maximum transactions allowed are 200 as described in Controlling maximum concurrent transactions.

  • NSJ 11 performs no conversion when calling a C or C++ routine where the function passes or returns parameters of type float or double. All float and double values remain in IEEE floating-point format when crossing the JNI boundary. For more information, see Floating-point implementation.

  • When using the JNI_OnLoad function, use the following format:

    jint JNI_OnLoad(JavaVM *vm, void *reserved);

  • The JNI_OnUnload function is supported.
  • Conform to the following rules when naming user DLLs:

    • Do not use names that begin with Tandem, tandem, or tdm.

    • NSJ 11 requires that all DLLs be named with a prefix lib and a suffix .so . Hence you must name your DLL as follows:

      libname.so

      where, (name) signifies the string that is passed to the System.loadLibrary () call.

The remainder of this subsection explains:

For more information about JNI, see Oracle JNI document.