Topic
  • 3 replies
  • Latest Post - ‏2012-02-23T18:23:19Z by SystemAdmin
TechBolek
TechBolek
2 Posts

Pinned topic Cannot use jni when running purify

‏2012-02-21T00:58:08Z |
I got a C++ app with calls to Java through JNI. When trying to purify the program can't get through JNI_CreateJavaVM. Interestingly, I get different behavior depending on the java version. For 1.6u16 it crashes with SIGSEGV. For 1.6u31 and 1.7u3 it get stuck in the call. Either way can't I get the program past the JVM initialization. Without purify the program runs fine. Any ideas?

OS: SunOS 5.10 Generic_142900-13 sun4v sparc SUNW,T5140

Compiler: Sun Studio 12

Purify Version: purify.sol.7.0.1.0-002

#include<jni.h>
#include<stdio.h>
int main(int argc, char* argv[])
{
printf("in main\n");
JNIEnv *env = NULL;
JavaVMInitArgs vm_args;
JavaVMOption * options = new JavaVMOption[1];
vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 0;
vm_args.options = options;
vm_args.ignoreUnrecognized = 0;

printf("creating vm....\n");
JavaVM * jvm = NULL;
int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if(ret < 0) {
printf("\nUnable to Launch JVM\n");
return(1);
}
printf("created!\n");
return 0;
}

Build script:

export JAVA_HOME=(.....)jdk1.6.0_31
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/sparcv9:$JAVA_HOME/jre/lib/sparcv9/server\
(....)/purify -handle-calls-to-java -always-use-cache-dir -cache-dir=(....) \
-best-effort -optimize-save-o7=no -max_threads=50 -threads=yes -mt_safe_malloc=yes\
/opt/installs/sun_studio/12/SUNWspro/bin/CC -mt -xcode=pic32 -xtarget=ultra -m64 -g\
-xs CTest.cpp -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -lpthread -lrt\
-L$JAVA_HOME/jre/lib/sparcv9 -L$JAVA_HOME/jre/lib/sparcv9/server -ljava -ljvm
Updated on 2012-02-23T18:23:19Z at 2012-02-23T18:23:19Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2948 Posts

    Re: Cannot use jni when running purify

    ‏2012-02-21T01:15:42Z  
    Hi TechBolek,

    Any chance your app will run under an older JRE? According to the release notes for
    PurifyPlus 7.0.1.0-002 (see "Java Support"), C/C++ data collection is only supported
    for older JREs. Now, I'm pretty sure I've talked to people who were using something
    newer than JRE 1.4.2 on Solaris, but if you go strictly by what is in the release notes,
    you really need to go with an older JRE if you want to use Purify. (I've attached a
    copy of the release notes for PPlus 7.0.1.0-002.)

    You might want to check with Tech Support to see what they recommend.
    Don
  • TechBolek
    TechBolek
    2 Posts

    Re: Cannot use jni when running purify

    ‏2012-02-21T17:40:46Z  
    Hi TechBolek,

    Any chance your app will run under an older JRE? According to the release notes for
    PurifyPlus 7.0.1.0-002 (see "Java Support"), C/C++ data collection is only supported
    for older JREs. Now, I'm pretty sure I've talked to people who were using something
    newer than JRE 1.4.2 on Solaris, but if you go strictly by what is in the release notes,
    you really need to go with an older JRE if you want to use Purify. (I've attached a
    copy of the release notes for PPlus 7.0.1.0-002.)

    You might want to check with Tech Support to see what they recommend.
    Don
    Thanks Don. According to the release notes they support up to Java 5. This is NOT what our app has ever used and recompiling it (plus the java jars) with Java 5 will be costly but might consider it.
    Thomas
  • SystemAdmin
    SystemAdmin
    2948 Posts

    Re: Cannot use jni when running purify

    ‏2012-02-23T18:23:19Z  
    Please submit the details of your failure with Java 6 JNI to tech support and open a ticket. That will enable us to work with you using the right channels and analyze the problem.