• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I pass a C pointer to a byte array and its length to Java

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can I pass a C pointer to a byte array and its length to Java using JNI?
The example I find are just passing integer. How can I pass a byte array and its length?

Thank you for any pointers.
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This chapter here (see 3.3) says about arrays in the JNI programming. If you want to return byte[] from a Java method (the array will internally have its length, so you don't need to pass it separately), try to compile it with javah and see what comes out. Then, using the methods described in the JNI Programmer's Guide you can convert the C array to a JNI-Java array and return it.
Thank you for any pointers.

Nice pun
 
Maneesh Godbole
Saloon Keeper
Posts: 11064
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More suitable for "Other java APIs" forum.
Moving
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic