Try to change the field Byte[] data = new Byte[2];
to byte[] data = new byte[2];
Then in your JNI method use GetFieldID(clsReturn, "data", "[B"));
Edit: To be able to get the internal signature of each type ([B
for byte[]
in your case) you can declare the field you want to a class (let's call it Test
), compile it and then run javap -s Test
. It produces an output like below:
Compiled from "SimpleMain.java"
public class SimpleMain extends java.lang.Object{
public byte[] data;
Signature: [B // <-- signature shows the internal type
public SimpleMain();
Signature: ()V
public static void main(java.lang.String[]);
Signature: ([Ljava/lang/String;)V
}