R
RThaden
Hi,
maybe somebody can help me out with this:
I have a C++ DLL which is called from a Java VM which works fine. I can
do callbacks from C++ to Java within the thread created by the VM.
I store the reference to the VM via env->GetJavaVM( &globalVM ) from
this thread in a global variable.
int CALLBACK func(LPVOID pCmd, LPVOID pParam)
{
JNIEnv* localEnv;
int rc = globalVM->AttachCurrentThread((void**) &localEnv, NULL);
rc = globalVM->GetEnv( (void**)localEnv, JNI_VERSION_1_2 );
if( rc == JNI_EDETACHED )
printf("GetEnv failed: thread not attached\n");
else
if( rc == JNI_EVERSION )
printf("GetEnv failed: wrong jni version\n");
else
if( rc == JNI_OK )
printf("GetEnv ssucceded\n");
localEnv->ExceptionClear();
...
At the last command, I get an unhandled exception in the Java VM.
However, the AttachCurrentThread and the GetEnv seem to work. At least,
they don't give negative numbers.
What am I doing wrong.
Any help appreciated,
Rainer
maybe somebody can help me out with this:
I have a C++ DLL which is called from a Java VM which works fine. I can
do callbacks from C++ to Java within the thread created by the VM.
I store the reference to the VM via env->GetJavaVM( &globalVM ) from
this thread in a global variable.
From a different thread I use the following code
int CALLBACK func(LPVOID pCmd, LPVOID pParam)
{
JNIEnv* localEnv;
int rc = globalVM->AttachCurrentThread((void**) &localEnv, NULL);
rc = globalVM->GetEnv( (void**)localEnv, JNI_VERSION_1_2 );
if( rc == JNI_EDETACHED )
printf("GetEnv failed: thread not attached\n");
else
if( rc == JNI_EVERSION )
printf("GetEnv failed: wrong jni version\n");
else
if( rc == JNI_OK )
printf("GetEnv ssucceded\n");
localEnv->ExceptionClear();
...
At the last command, I get an unhandled exception in the Java VM.
However, the AttachCurrentThread and the GetEnv seem to work. At least,
they don't give negative numbers.
What am I doing wrong.
Any help appreciated,
Rainer