58,454
社区成员
发帖
与我相关
我的任务
分享
static int invokeJava(char *args)
{
jclass notifyJavaCls;
jmethodID notifyJavaMethod;
JNIEnv *notifyJavaEnv;
jint status = jvm->AttachCurrentThread((void **)¬ifyJavaEnv, NULL);
if(status < 0 ){
cout<<"AttachCurrentThread failed"<<endl;
return -1;
}
notifyJavaCls = notifyJavaEnv->GetObjectClass(notifyJavaObj);
if(notifyJavaCls == NULL){
cout<<"GetObjectClass failed"<<endl;
return -1;
}
notifyJavaMethod = notifyJavaEnv->GetMethodID(notifyJavaCls, "getVxworksEventArg", "(Ljava/lang/String;)I");
if(notifyJavaMethod == 0){
cout<<"GetMethodID failed"<<endl;
return -1;
}
jstring eventArgs = WindowsTojstring(notifyJavaEnv, args);
notifyJavaEnv->CallIntMethod(notifyJavaObj, notifyJavaMethod, eventArgs);
jvm->DetachCurrentThread();
return 0;
}