jni compilation problem
hello,
I'm trying to make an interface between java and a c++ program.
I get everything wroking except for one method. And I have no clue how to solve it.
I have a function in c++ :
SchedulerOsa::SchedulerOsa (JNIEnv *env, jobject obj)
{
printf("osa sched created\n");
env_ = env;
obj_ = obj;
}
Event
SchedulerOsa::insert (Event event, Scheduler::EventKey key)
{
std::cout << "osa insert uid " << key.m_uid << std::endl ;
cls_ = env_ -> GetObjectClass(obj_);
std::cout << "osa insert51 " << cls_ << std::endl ;
if (cls_ == 0){
std::cout << "ERROR! Unable to get method identifier for because the class is NULL." << std::endl ;
}
mid_ = env_ -> GetMethodID(cls_,"insertYansEvent","(IIJ)V");
if (mid_ == 0){std::cout << "ERROR! Unable to get method identifier for "<< std::endl ;
}else{
std::cout << "osa insert7 " << obj_ << " , " << &env_ << " , " << mid_ << " , " << (jint)key.m_uid << " , " << (jint) time << " , " << (jlong)g << std::endl;
env_->CallVoidMethod(obj_,mid_,(jint)key.m_uid, (jint) time, (jlong)g);
}
printf("osa insert8\n");
return event;
}
my c++ code calls the function SchedulerOsa::insert twice. In the first call, the system call my java function (CallVoidMethod) but, in the second call, i have an error :
[java]Library hello successfully loaded
[java] osa sched created
[java] schedule_abs_us
[java] osa insert uid 0
[java] osa insert5
[java] osa insert51 0x81c0c58
[java] osa insert6
[java] osa insert7 0xb167b9b4 , 0x81c4b5c , 0x81c4e30 , 0 , 0 , 136071984
[java] osa insert8
[java] executeNextEvent..........0 ,
[java] send next pkt
[java] schedule_abs_us
[java] osa insert uid 1
[java] osa insert5
[java] osa insert51 0x81c0bb8
[java] #
[java] # An unexpected error has been detected by HotSpot Virtual Machine:
[java] #
[java] # SIGSEGV (0xb) at pc=0xb79f2d0f, pid=5606, tid=2974092208
[java] #
[java] # Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
[java] # Problematic frame:
[java] # V [libjvm.so+0x16dd0f]
[java] #
[java] # An error report file with more information is saved as hs_err_pid5606.log
[java] #
[java] # If you would like to submit a bug report, please visit:
[java] #http://java.sun.com/webapps/bugreport/crash.jsp
[java] #
the system blocked in
mid_ = env_ -> GetMethodID(cls_,"insertYansEvent","(IIJ)V");
i don't understand why through the system works in the first time, it doest not work in the second call ? Have you an explanation?
Could anybody please help me out on this ?
Either solution would be good for me, but pure for extending my knowledge It would be great if someone could shed some light on the first approach also please.
Thanks for your time and knowledge sharing

