title: Return a 2D primitive array from C to Java from JNI/NDK
body: <p>I have found large amounts of documentation on how to generate a 2D primitive array in JNI and returning it to Java. But these pieces of information fail to describe how to pass an <strong>already existing</strong> 2D float array (float**) given a context in <strong>C</strong>.</p>
  
  <p>To describe my issue explicitly, I'll add some <strong>C</strong> pseudo code of what I would like to implement:</p>
  
  <pre><code>// Returns a 2D float array from C to Java
  jfloatArray ndk_test_getMy2DArray(JNIEnv* env, jobject thiz, jlong context)
  {
      // Cast my context reference
      MyContextRef contextRef = (MyContextRef) context;
  
      // In case we need it below
      unsigned int length = MyContextGet1DLength(contextRef);
  
      // Get the 2D Array we want to "Cast"
      float** primitive2DArray = MyContextGet2DArray(contextRef);
  
      // Hokus pokus...
      // We do something to create the returnable data to Java
      //
      // Below is the missing piece that would convert the primitive
      // 2D array into something that can be returned consumed and consumed
      // by Java
  
      jfloatArray myReturnable2DArray
  
      return myReturnable2DArray;
  }
  </code></pre>
  
  <p>I'm assuming this is not straight forward, given I haven't been able to find anything describing this scenario.</p>
  
  <p>Thanks for any helpful information.</p>