NonStop Server for Java 7.0 Programmer's Reference
NOTE: If the native code has large variables on the stack, then calling this native code might
exceed the default stack space provided for each thread. If the native code exceeds the amount
of stack space allocated for it, then it results SIGSTK.
To prevent overflowing the available stack space, consider allocating large variables on the
heap rather than using the stack. Otherwise, you can increase the default stack size for each
thread by specifying the -Xss option when starting java. This option increases the stack size
for every thread.
For more information about the -Xss option, see java in the NonStop Server for Java 7.0
Tools Reference Pages.
4. Create a DLL file (.so file type) and specify the linker option as explained in “Linker and
compiler options” (page 38).
After specifying the linker option, set the _RLD_LIB_PATH environment variable to point to
where the created DLL file resides by using the following command:
export _RLD_LIB_PATH=dll-path
where, dll-path is the directory where the user DLL resides.
For example:
/usr/bin/eld TandemWrap.o SystemInfo.o -o libCompanySysInfo.so -set SYSTYPE OSS -set HIGHPIN ON -set
data_model lp64 -set CPlusPlusDialect neutral -dll -lcre -lcrtl -export_all
For more information, see “_RLD_LIB_PATH” (page 26).
NOTE: Using neutral data type DLL may not work with 64–bit JDK as JVM pass true 64–bit
pointers that is not sign-extended value of a 32–bit pointer.
The javahjni demo shows an example of how to create a library file, see Table 4 (page 29) to
view the directory location of the demo programs. The demo also shows the conversion between
the TNS and IEEE floating-point.
Calling Java methods from C or C++
You can create your own C or C++ program. Follow these guidelines to use the Invocation API to
load the JVM in an arbitrary native program:
• NSJ7 supports only the POSIX User Thread library. As a result, the following issues must be
considered when migrating to NSJ7:
◦ Java application which uses the Invocation API must necessarily link with the POSIX User
Thread library. An application must link with either ZPUTDLL or YPUTDLL depending
on whether it is a 32–bit or 64–bit application.
Set the _RLD_LIB_PATH environment variable to the location of libjvm.so as shown:
For 32–bit NSJ7: $ export _RLD_LIB_PATH=$JREHOME/lib/oss/server/
For 64–bit NSJ7: $ export _RLD_LIB_PATH=$JREHOME/lib/oss64/server/
• A native application can use the JNI_CreateJavaVM() call to become a Java process,
and such applications are called JNI applications. The native application can be either
multi-threaded or single threaded. If an application calls the JNI_CreateJavaVM() on the
main thread, then the main thread becomes the Java thread after creating the virtual machine.
If an application already contains a VM, another thread can become a Java thread by invoking
AttachCurrentThread(). In either case, if the calling thread is the main thread and if
distributed GC is enabled, the main thread stack must be shared by GC processes. As the
main thread stack cannot be shared across GC processes, the distributed GC cannot be
enabled when the main thread is the Java thread. Hence, JNI_CreateJavaVM() and
Java native interface (JNI) 37










