android - How to pass a structure as an argument to java function or return to java from jni -


i have 2 questions have structure in jni

struct x {     type_a x;     type_b y; } 

now how i?

  1. pass structure argument java call function
  2. how return structure java function.

if possible, please give example.

if pass data structure java, must java object. can either create on jni side, or fill in parameter object passed jni java. (e.g. java can create new byte[4096] , pass jni function store result there.)

but want java store pointers native structures. cast such pointer int/long , pass java. no java garbage collector free such memory, have explicitly (as in c). in addition, need call jni function free such memory. play finalize(), i'd recommend explicit deallocation @ predictable times predictable threads(!).


Comments