By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.


P: 1

My requirement is to use Direct Buffers and share a common memory between Java and C++.

I have created a ByteBuffer in java using allocateDirect and sent the same to JNI. In JNI i have called GetDirectBufferAddress() and got the address of ByteBuffer and sent the same to my C++ library as char* through SetByteBuffer() function.

Now i have to do getByteBuffer() from Java, which should return me the direct allocated buffer. In C++ i am returning the same char* pointer in GetByteBuffer() method and JNI is able to get the elements properly. Now i am dont now how to send this char* to Java as ByteBuffer or jByteArray() with out creating a new memory and copying the data. Can any one provide a solution to me.
Feb 16 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.