title: JNI DETECTED ERROR IN APPLICATION: use of invalid jobject
body: <pre><code>public class MyOpaqueBasedJSONDict implements IMyJSONDict {
  
      private final long _myNativeCPPObj;
  ...
  
  public IMyJSONDict getMyJSONObj(String keyName) {
          long retVal = nativeGetJSOBObject(_myNativeCPPObj,keyName);
          return (new MyOpaqueBasedJSONDict(retVal));
      }
  
  native implementation
  NIEXPORT jlong JNICALL
  Java_com_hexample_myndkapplication_MyOpaqueBasedJSONDict_nativeGetJSOBObject(JNIEnv *env,
                                                                               jobject instance,
                                                                               jlong myNativeCPPObj,
                                                                               jstring keyName_) {
      const char *keyName = env-&gt;GetStringUTFChars(keyName_, 0);
  
      Json::Value* nativeCppJson_ptr = reinterpret_cast&lt;Json::Value*&gt; (myNativeCPPObj);
  
      Json::Value&amp; map = *nativeCppJson_ptr;
  
      Json::Value&amp; jsonVal = map[keyName];
      env-&gt;ReleaseStringUTFChars(keyName_, keyName);
      return (jlong) &amp;jsonVal;
  }
  </code></pre>
  
  <p>I am not able to understand why I am getting </p>
  
  <blockquote>
    <p>JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0xb4019a80
    08-16 03:25:56.785 20537-20537/com.hexample.myndkapplication A/art:
    art/runtime/java_vm_ext.cc:410]     from long
    com.hexample.myndkapplication.MyOpaqueBasedJSONDict.nativeGetJSOBObject</p>
  </blockquote>
  
  <p>Any clue how to debug invalid memory errors in ndk. I am pretty new to Android and ndk development.</p>