NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)
(/usr/tandem/java/include/oss/dce).
Use Pthread wrappers for any functions that mandate thread-aware activity, such as socket I/O, file I/O, and pipes.●
Because Pthreads are user-level threads, the operating system does not schedule each thread independently, and therefore,
operating system calls from a user thread can block the entire JVM rather than only the active thread. Pthread wrappers prevent
this problem. Each Pthread wrapper registers its call with the Pthread dispatcher, uses the appropriate NOWAIT operation for the
call, and then suspends the thread. After the NOWAIT operation completes, the Pthread dispatcher resumes the appropriate thread.
NonStop SQL/MP or SQL/MX operations invoked by the Type 2 JDBC Driver for SQL/MP or JDBC Driver for SQL/MX block
the JVM until the operation is completed (that is, these operations are not threaded).
Sockets
Use only the NonStop Java 2.1 socket implementation in java.net (the standard Java socket). All socket I/O calls are
thread-safe and nonblocking.
If you use a socket in a native call, you do not benefit from multithreading functionality. The socket call blocks the entire JVM. If
you use Java sockets, the JVM can schedule other threads while one thread is waiting for socket completion.
Calling Java Methods From C or C++
You can create your own C or C++ program and use the Invocation API to load the Java Virtual Machine (JVM) into an arbitrary
native program. Code written in C++ must be compiled using the -Wversion2 compiler command-line option. In the Compaq
environment, you must link the JVM archives into the custom-built main program.
A program using the Invocation API to start a JVM does not have its function returns and parameters of type float or double
automatically converted between IEEE floating-point format and Compaq floating-point format. The Guardian Procedure Calls
Manual documents a series of procedures with names beginning with NSK_FLOAT_ that can be used to convert float and
double data between the two formats.
To run the Invocation API demo, follow the instructions for the Invocation API demo in the README file in the directory
/usr/tandem/java/demo/invocation_api.
Using the compaq.liblist System Property
By default, NonStop Java does not throw an UnsatisfiedLinkError exception when System.load or
System.loadLibrary are called for a library that has not been statically linked into the Java Virtual Machine. An
UnsatisfiedLinkError is thrown, however, when a native method is invoked if that native method does not exist in the
JVM. NonStop Himalaya systems do not have dynamically linked libraries.
To catch an UnsatisfiedLinkError during a call to load or loadLibrary when a static library has not been linked into
the JVM, instead of catching the error when the native method is called:
Override the value of GENLIBLIST in the Makefile. Either edit the Makefile to change the default NO value to YES
or override the value on the command line to make. For example:
make GENLIBLIST=YES
This causes make to generate a file called JavaLibList in the same directory as the target Java program. The
JavaLibList contains a list of libraries known to be statically linked into the JVM just built. This file lists several
internal libraries that should not be removed or changed.
1.
Execute java and set the compaq.liblist system property to refer to the JavaLibList file generated during the
make operation. For example:
java -Dcompaq.liblist=/usr/tandem/java/bin/oss/posix_threads/JavaLibList class-name
2.