IBM Support

Troubleshooting: JNI Checklist

Question & Answer


Question

Troubleshooting: JNI Checklist

Cause

The following is a checklist actions to diagnose JNI problems. Although the list is not a complete, it can be use to resolve most JNI problems using IBM Java for AIX
The details in this document make references to generic terms in Italics that will need to be replaced with information specific to the support call and the environment. It is very important that consistent and accurate values be used in place of the Italicized generic terms when collecting the data to ensure the prompt and correct delivery of the data when uploaded.
Generic Term Replace with
lib_dir The list of directories that are search for shared objects. These directories contain the Java SDK shared libraries.
Checklist
Details
Examples / Tips / Hints / Comments / Descriptions

Set AIX Thread Variables

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

Setting LIBPATH

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

Setting MAXDATA

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

JNI Linking

Ensure JNI runtime linking is setup correctly

see: JNI Runtime Linking

Debugging JNI

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

Tracing JNI

Adding -verbose:jni writes information to stderr describing the JNI services called by the application and JVM.

java -verbose:jni JavaProgram

Item 7:

TITLE

Item 8:

TITLE

Item 9:

TITLE

Item 10:

TITLE

Item 11:

TITLE

Item 12:

TITLE

Item 13:

TITLE

Item 14:

TITLE

Item 15:

TITLE

Item 16:

TITLE

Item 17:

TITLE

Item 18:

TITLE

Item 19:

TITLE

Item 20:

TITLE

Item 21:

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

[{"Product":{"code":"SG9NGS","label":"IBM Java"},"Business Unit":{"code":null,"label":null},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 June 2018

UID

isg3T1024955