Thank you for the background information. There is different JNI issue that I am encountering.
I was invoking a static function member from the native code. At this point, I dont mind using a static function member, but for thread safety in subsequent release, I need to switch it to use an instance function member. I saw the documentation about using non-static function members. And I think I updated the code to use it correctly. But it encounters a runtime crash in the jvm. the crash and java and native code fragments follows: static callback invoked from native: 7870.00 static callback passing integer invoked. 333 # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (jni.cpp:947), pid=1852, tid=5864 # Error: ShouldNotReachHere() # # JRE version: 6.0_32-b05 # Java VM: Java HotSpot(TM) Client VM (20.7-b02 mixed mode, sharing windows-x86 ) # An error report file with more information is saved as: # C:\Users\sk\workspace\osg\osgnativelib\hs_err_pid1852.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (jni.cpp:947), pid=1852, tid=5864 # Error: ShouldNotReachHere() # # JRE version: 6.0_32-b05 # Java VM: Java HotSpot(TM) Client VM (20.7-b02 mixed mode, sharing windows-x86 ) # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # --------------- T H R E A D --------------- Current thread (0x0264a800): JavaThread "main" [_thread_in_vm, id=5864, stack(0x00550000,0x005a0000)] Stack: [0x00550000,0x005a0000], sp=0x0059f878, free space=318k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [jvm.dll+0x13373a] V [jvm.dll+0x12e6db] V [jvm.dll+0x9529c] V [jvm.dll+0x95a27] V [jvm.dll+0x9890c] C [HelloWorldWin32Library.dll+0x116d3] JNIEnv_::CallVoidMethod+0x43 C [HelloWorldWin32Library.dll+0x14274] Java_com_foo_osgjni_core_MathFuncTest_Multiple+0x114 j com.foo.osgjni.core.MathFuncTest.Multiple(DD)D+0 j com.foo.osgjni.core.MathFuncTest.main([Ljava/lang/String;)V+15 v ~StubRoutines::call_stub V [jvm.dll+0xfad4b] V [jvm.dll+0x18c421] V [jvm.dll+0xfadcd] V [jvm.dll+0x95836] V [jvm.dll+0x9d673] C [javaw.exe+0x2155] C [javaw.exe+0x8614] C [kernel32.dll+0x1339a] BaseThreadInitThunk+0x12 C [ntdll.dll+0x39ed2] RtlInitializeExceptionChain+0x63 C [ntdll.dll+0x39ea5] RtlInitializeExceptionChain+0x36 Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.foo.osgjni.core.MathFuncTest.Multiple(DD)D+0 j com.foo.osgjni.core.MathFuncTest.main([Ljava/lang/String;)V+15 v ~StubRoutines::call_stub #define STATICMETHODFUNCTIONNAME "callback" #define FUNCTION_SIGNATURE "(Ljava/lang/String;)V" #define STATICCALLNUMBERFUNCTIONNAME "callnumber" #define STATICCALLNUMBERFUNCTION_SIGNATURE "(I)V" #define INSTANCEMETHODFUNCTIONNAME "callbackInstance" #define INSTANCE_FUNCTION_SIGNATURE "(I)V" JNIEXPORT jdouble JNICALL Java_osgjni_core_MathFuncTest_Multiple (JNIEnv *penv, jobject obj, jdouble left, jdouble right) { jdouble product = left * right; jclass cls = penv->GetObjectClass(obj); jmethodID midStatic = penv->GetStaticMethodID(cls, STATICMETHODFUNCTIONNAME, FUNCTION_SIGNATURE); jmethodID midStaticNumber = penv->GetStaticMethodID(cls, STATICCALLNUMBERFUNCTIONNAME, STATICCALLNUMBERFUNCTION_SIGNATURE); jmethodID midInstance = penv->GetMethodID(cls, INSTANCEMETHODFUNCTIONNAME, INSTANCE_FUNCTION_SIGNATURE); char buffer[20]; sprintf(buffer, "%5.2f", product); jstring jstr = penv->NewStringUTF(buffer); if (midStatic != 0) { penv->CallStaticVoidMethod(cls, midStatic, jstr); } if (midStaticNumber != 0) { penv->CallStaticVoidMethod(cls, midStaticNumber, 333); } if (midInstance != 0) { penv->CallVoidMethod(cls, midInstance, 10); } return product; } public class MathFuncTest { native double Multiple (double left, double right); static { System.load("c:\\DEV\\src\\test\\Debug\\HelloWorldWin32Library.dll"); } /** * this is used for the static function member test. * @param msg */ public static void callnumber (int number) { System.out.println("static callback passing integer invoked."); System.out.println(number); } /** * this is used for the static function member test. * @param msg * * */ public static void callback(String msg) { //System.out.println(msg); if (msg != null){ System.out.println("static callback invoked from native: "+ msg); } } /** * this is used for the instance function member test. * @param msg * * */ public void callbackInstance (int number) { System.out.println("instance callback invoked from native: "+ number); } /** * @param args */ public static void main(String[] args) { MathFuncTest test = new MathFuncTest(); double product = test.Multiple(10, 787); System.out.println("native java: product is : "+product); } } _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org