title: Passing 2D bytearray to C Jni
body: <p>I wanted to pass on a 2D byte array from Java to C++ using JNI, everything seems fine, but I can't get the value of the third array.</p>
  
  <p>Java:</p>
  
  <pre><code>    byte[][] b = new byte[3][];
      byte[] b1= new byte[]{0x1,0x2,0x3,0x4};
      byte[] b2= new byte[]{0x5,0x6,0x7,0x8};
      byte[] b3= new byte[]{0x9,0x9,0x9,0x9};
      b[0]=b1;
      b[1]=b2;
      b[2]=b3;
      sendData(b);
  </code></pre>
  
  <p>C++:</p>
  
  <pre><code>JNIEXPORT jbyteArray JNICALL Java_jni_JniExample_sendData___3_3B
    (JNIEnv *env, jobject obj, jobjectArray data)
  {
          jboolean isCopy;
          uint8_t** y = new uint8_t*[3];
          for(int i=0;i&lt;3;i++)
          {
                  jbyteArray bytearray  = (jbyteArray)env-&gt;GetObjectArrayElement(data, i);
                  y[i]  = (uint8_t *)env-&gt;GetPrimitiveArrayCritical(bytearray, &amp;isCopy);
                  cout &lt;&lt; i &lt;&lt; " " &lt;&lt; y[i]  &lt;&lt; endl;
          }
  
  }
  </code></pre>
  
  <p>The output that I get is:</p>
  
  <pre><code>0 0x1 0x2 0x3 0x4
  
  1 0x5 0x6 0x7 0x8
  
  2
  </code></pre>
  
  <p>I can't reach the values for the third array. Am I using GetPrimitiveArrayCritical correctly?</p>