Remote call to JNI method - Error returning a jDateClass object
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Veena_Pandiri
Posted On:   Thursday, September 19, 2002 08:10 AM

When an external JVM makes a remote call to C++, it hangs on creating the jDataClass. Does anyone has an idea of how to debug this any further? I am not sure how to capture cout or catch and display an exception in this case because it is a different process. The following is the code for copying the C++ date (stRestrictedRegionData) structure to the jobject jdRestrictedAdd: //Date dRestrictedAdd jclass jDateClass = jEnv->FindClass("java/util/Date"); mid1 = jEnv->GetMethodID(jDateClass, " ", "(III)V"); if (mid1 != 0) { jint jnYear = stRestrictedRegionData.dRestrictedAdd.nYear - 1900;    More>>

When an external JVM makes a remote call to C++, it hangs on creating the jDataClass. Does anyone has an idea of how to debug this any further? I am not sure how to capture cout or catch and display an exception in this case because it is a different process.


The following is the code for copying the C++ date (stRestrictedRegionData) structure to the jobject jdRestrictedAdd:


//Date dRestrictedAdd


jclass jDateClass = jEnv->FindClass("java/util/Date");


mid1 = jEnv->GetMethodID(jDateClass, " ", "(III)V");


if (mid1 != 0)


{


jint jnYear = stRestrictedRegionData.dRestrictedAdd.nYear - 1900;


jint jnMonth = tRestrictedRegionData.dRestrictedAdd.nMonth- 1;


jint jnDay = stRestrictedRegionData.dRestrictedAdd.nDay;


jdRestrictedAdd = jEnv->NewObject(jDateClass, mid, jnYear, jnMonth, jnDay);


objException = jEnv->ExceptionOccurred();


if (objException != NULL)


{


return CAP1_RTN_FAILURE;


}


}

   <<Less

Re: Remote call to JNI method - Error returning a jDateClass object

Posted By:   Alexander_Krapf  
Posted On:   Monday, September 23, 2002 02:40 PM

Hi Veena,


I would first of all check for exceptions before and after the first line of code. Many problems in JNI have to do with an unhandled exception in an earlier call.


Also, is your jEnv the current call environment? You must never cache the JNIEnvironment pointer.


If you are working on a commercial project and are interested in a product to make your life easier, you could also check out JunC++ion, a tool that allows you to sidestep JNI completely by using generated C++ procy classes instead. Take a look at the posted code examples on Codemesh's website.


Regards,


Alex

About | Sitemap | Contact