B4Alpha-Aft3r0mega / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

byte array data (google protobuf) corrupted #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Serialize a protobuf message to byte array at Java side then pass it to 
JavaCPP.
2. It's a signed char array in C++ that matches byte array in Java via JavaCPP. 
When C++ gets the signed char array then return it to Java immediately. 
3. Java receives the byte array and compares with the original byte array. It's 
different.

What is the expected output? What do you see instead?
The message go though JavaCPP should not be corrupted.
e.g.
Before is [B@30c2ea0b
After is [B@4c93912f

What version of the product are you using? On what operating system?
JavaCPP 0.8. CentOS-5.8-x86_64

Please provide any additional information below.

Original issue reported on code.google.com by yhan-sus...@rubiconproject.com on 8 Aug 2014 at 6:15

GoogleCodeExporter commented 8 years ago
Native objects can't hold on to Java arrays, not without using JNI manually 
anyway. We need to use `BytePointer` to do what you describe. 

And please post your questions/issues on GitHub or on the mailing list next 
time, if possible, thank you!

Original comment by samuel.a...@gmail.com on 9 Aug 2014 at 1:19