Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing byte array back to Java

843829Oct 19 2001 — edited Oct 24 2001
In Java when I am calling the getBytes(bytes) I do not know the size of the byte array. Only in the C++ code I will know how long the Byte Array is going to be.

In C++ I just want to copy "cbytes" into "jbytes" such that I will be able to make use of it in Java.

Java Code:
----------------
private static native int getBytes(byte[] bytes);
.
.
byte[] bytes = null;
int status = getBytes(bytes)
..
..
C++ Code
---------------

JNIEXPORT jint JNICALL Java_getBytes
(JNIEnv *, jclass, jbyteArray jbytes)
{

char * cbytes = getCBytes();
//

return 0;

}

Could some one let me know how this can be achieved.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2001
Added on Oct 19 2001
5 comments
515 views