• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jni: transfer a 2 dimension java array to c program.

 
Kejia Jiarui
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java, a 2 dimension array, Integer[][], is defined. How should one access the array arr in a C program via JNI?


 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through the default functions:
- GetFieldID to get a reference to the field.
- GetObjectField to get the field value.
- GetArrayLength to get the array length.
- GetObjectArrayElement to get the inner arrays and the Integers from them.

If you switch to an int[][] you must use GetIntArrayElements and ReleaseIntArrayElements to access the innermost elements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic