One, JNI Java tune C + + dynamic library function problem
1. Multi-Parameter callback
2. Parameter passing is garbled
Second, to solve
1. Using the byte[] array in C + +, the generated header file will become the Jbytearray type
For example, in Java parameters: Byte[]account, the parameters in the header file become Jbytearray account,
After modifying the value of the account through C + +, Java wants to get the value, directly using the
jbyte* Jbaccount = (env)->getbytearrayelements (env, account, 0);
char* Szaccount = (char*) jbaccount;
The address of the pointer is not the address of the account, and the value is finally assigned.
Env->setbytearrayregion (Account,0,strlen (szaccount), jbyte* jbaccount);
2.string.getbytes () The resulting byte array is passed into C + +, there will be extra garbled characters at the end of the string.
The workaround is to pass the length of the array to C + + when passing in a byte array,
Make the accepted array strbuff[length]= ' \ n '; solve the problem
JNI Java C + + Dynamic library function, multi-value callback and garbled problem