Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / April 2006

Tip: Looking for answers? Try searching our database.

JNI FindClass coredumps with JRE 1.5

Thread view: 
abhijit.dhariya@gmail.com - 31 Mar 2006 15:57 GMT
I have a sample program, please see below.
This program exe runs fine with JRE 1.4 on AIX 5.2.
But same exe causes core dump with JRE 1.5 on AIX5.2.

Any idea why this should happen?
(I did set all environment variables required - LDR_CNTRL,
AIXTHREAD_SCOPE etc)
Do I need to compile my sample program with JDK 1.5??

Please let me know if anyone has came across such issues with JRE 1.5.

Thanks in advance.
-Abhijit

Sample Program:
============
int main(){

   JavaVM *jvm;       /* denotes a Java VM */
   JNIEnv *env;       /* pointer to native method interface */

   JavaVMInitArgs vm_args;
   JavaVMOption options[5];
   char* classpathVar = (char*)"-Djava.class.path=.";
   options[0].optionString =
            (char*)"-Djava.compiler=NONE";// disable JIT
   options[1].optionString = classpathVar;// user classes

   options[2].optionString =
          (char*) "-Djava.library.path=.";// set native library path
   options[3].optionString =
           (char*)"-verbose:jni";// print JNI-related messages
   options[4].optionString =
           (char*)"-Xcheck:jni";// print JNI-related messages

   vm_args.version = JNI_VERSION_1_4;
   vm_args.options = options;
   vm_args.nOptions = 5;
   vm_args.ignoreUnrecognized = JNI_FALSE;

   /* load and initialize a Java VM, return a JNI interface
    * pointer in env */
   jint retValue = 0;
   retValue = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
   cout << "Return value : " << retValue << endl;
   /* invoke the Main.test method using the JNI */
   jclass cls = env->FindClass("java/lang/string");
   //jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
   //env->CallStaticVoidMethod(cls, mid, 100);
   cout << "Done "<< endl;

   /* We are done. */
   jvm->DestroyJavaVM();
return 0;
Gordon Beaton - 31 Mar 2006 17:21 GMT
> I have a sample program, please see below.
> This program exe runs fine with JRE 1.4 on AIX 5.2.
> But same exe causes core dump with JRE 1.5 on AIX5.2.

There are at least 3 things wrong with the program:

- you spelled java/lang/String wrong
- you fail to check that the call succeeds before using the result in
 the next call
- last I checked there was no test() method in the String class.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

abhijit.dhariya@gmail.com - 31 Mar 2006 21:09 GMT
ok but same sample works fine -- atleast executation -- with JRE 1.4.0.
Issue is with my class name inside FindClass, even though I have that
in class path it causes core dump.
like: FindClass("/com/test/myClass")
Anything wrong in syntax? I mean should it be
FindClass("L/com/test/myClass;")

I have commented out next 2 lines after FindClass, so test() method
will not get called anyway.
Gordon Beaton - 01 Apr 2006 09:30 GMT
> ok but same sample works fine -- atleast executation -- with JRE
> 1.4.0. Issue is with my class name inside FindClass, even though I
> have that in class path it causes core dump. like:
> FindClass("/com/test/myClass") Anything wrong in syntax? I mean
> should it be

> FindClass("L/com/test/myClass;")

No, it's exactly "com/test/myClass", without any extra characters
before or after.

You claim that you have set up the environment correctly, but perhaps
your launcher is unable to link to all of the necessary libraries
(.so), or is finding a combination of libraries from two JVMs, or
something along those lines. Check that LD_LIBRARY_PATH (or the AIX
equivalent) is correct. Use ldd to see exactly what is being found.

Try also removing the call to DestroyJavaVM.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.