title: Is a jbyteArray a jobject (i.e.: as a parameter to DeleteLocalRef)?
body: <p>In JNI, is a jbyteArray considered a jobject?  I.e.: if I have some long-running C++ code, can I use code like the following to release the object reference?</p>
  
  <pre><code>JNIEnv* env;
  
  jobject getJavaObj(bool useArray) {
      if (useArray) {
          jbyteArray dataArray = env-&gt;NewByteArray(getDataSize());
          env-&gt;SetByteArrayRegion(dataArray, 0, getDataSize(), dataPtr);
          return static_cast&lt;jobject&gt;(dataArray)
      } else {
          jobject javaByteBuffer = env-&gt;NewDirectByteBuffer(dataPtr, getDataSize());
          return javaByteBuffer;
      }
  }
  
  // ...
  jobject theData = getJavaObj(true);
  // ... Code to use theData jobject goes here...
  env-&gt;DeleteLocalRef(theData); // Will this cause any issues?
  </code></pre>
  
  <p>The JDK's jni.h include file seems to indicate that this would be a correct assumption, but I can't find much on the web to back up this assumption:</p>
  
  <pre><code>#ifdef __cplusplus
  class _jobject {};
  ...
  class _jarray : public _jobject {};
  typedef _jbyteArray *jbyteArray;
  #else
  ....
  #endif
  </code></pre>
  
  <p><strong>Background:</strong></p>
  
  <p>I have some JNI code which has a memory leak that I'm trying to pin down.  The total process size keeps increasing, but JConsole says the JVM's heap memory usage and non-heap usage are remaining fairly constant.  So my conclusion is that the leak must be in the raw C++ itself, or in the JNI code.</p>