2 Replies Latest reply on Feb 20, 2013 7:48 PM by jschellSomeoneStoleMyAlias

    attached native thread can't find class

      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