Question & Answer
Question
Troubleshooting: JNI Checklist
Cause
Generic Term | Replace with |
lib_dir | The list of directories that are search for shared objects. These directories contain the Java SDK shared libraries. |
Ensure the following variables are set
If you are writing a C or C++ program that uses the JNI Invocation API (that is, the program creates a Java Virtual Machine and calls Java code), ensure that the following variables are set appropriately. By default, all the Java launchers that are shipped with the SDK (for example, java, jar) set up these environment variables to the values that are specified as follows
AIXTHREAD_SCOPE=S
AIXTHREAD_MUTEX_DEBUG=OFF
AIXTHREAD_RWLOCK_DEBUG=OFF
AIXTHREAD_COND_DEBUG=OFF
export AIXTHREAD_SCOPE=S
export AIXTHREAD_MUTEX_DEBUG=OFF
export AIXTHREAD_RWLOCK_DEBUG=OFF
export AIXTHREAD_COND_DEBUG=OFF
Set the LIBPATH and use correct compile flags
When you build a C or C++ program that uses the invocation API, your LIBPATH variable must include the directories that contain the JVM shared libraries, lib_dir and lib_dir/j9vm, as well as the directories that contain the application's shared libraries.
If you are using the 32-bit java executable, JNI executables and shared objects should be built as 32-bit executables or shared objects using -q32 (default). For the 64-bit SDK, they should be built as 64-bit programs or shared objects, using the -q64 option.
export LIBPATH=/usr/java7/jre/lib/ppc/j9vm
xlC -q32
xlC -q64
For 32-bit applications, set the MAXDATA
The LDR_CNTRL environment variable controls the way AIX handles the memory space available to a 32-bit program..To use a Java heap larger than 2.5 GB, set MAXDATA to a different value.
export LDR_CNTRL=MAXDATA=0XA0000000@DSA
Debugging the JNI
If you think you have a JNI problem, there are checks you can run to
diagnose the JNI transitions.
Errors in JNI code can occur in several ways:
- The program crashes during execution of a native method (most common).
- The program crashes some time after returning from the native method, often
during GC (not so common).
- Bad JNI code causes deadlocks shortly after returning from a native method
(occasional).
If you think that you have a problem with the interaction between user-written native code and the JVM (that is, a JNI problem), you can run checks that help you diagnose the JNI transitions. To run these checks, specify the -Xcheck:jni option when you start the JVM.
java -Xcheck:jni JavaProgram
Tracing JNI
Adding -verbose:jni writes information to stderr describing the JNI services called by the application and JVM.
java -verbose:jni JavaProgram
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
TITLE
Document Type: | Description |
Content Type: | Howto | Troubleshooting | Mustgather | Workaround | FAQ | Alert |
Hardware: | all Power | Power5 | Power6 | Power7 | Power8 |
Operating System: | all AIX Versions | AIX 6 | AIX 7 |
IBM Java: | all Java Versions | Java 5.0 | Java 6.0 | Java 6.1 | Java 7.0 | Java 7.1 | Java 8.0 |
Author(s): | John Carver |
Reviewer(s): | John Carver |
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
isg3T1024955