This discussion is archived
2 Replies Latest reply: Feb 20, 2013 11:48 AM by jschellSomeoneStoleMyAlias RSS

attached native thread can't find class

991423 Newbie
Currently Being Moderated
I've got a JNI C DLL that responds to callbacks from a 3rd party DLL. From those callbacks, I want to call methods of a java object.

The java object instance is stored as a global ref.
The JVM pointer is captured in JNI_OnUnload().
AttachCurrentThread() seems to succeed and return a valid (i.e. non-null) JNIEnv* to the callback thread.

However, during the callback thread's code sequence, it calls pEnv->FindClass(...) and FindClass is returning null. The arg to FindClass() is a valid class path.

When I hack my code and explicitly call the callback thread's code sequence from another JNI function called from Java (i.e. it is passed a JNIEnv* as its first argument), the code sequence executes without a hitch. But when that same code sequence is called from the callback thread, it fails as described above.

What could be wrong with the JNIEnv* gotten from the callback thread calling AttachCurrentThread()?

Edited by: 988420 on Feb 16, 2013 6:31 AM


  • Correct Answers - 10 points
  • Helpful Answers - 5 points