c++ byte[] to jbytearray

hi, in the c++ code I have a byte array, I need to convert it to jbytearray and call a java method from there.

I'm using this code but the compiler complains about conversions (of course)

jbyteArray jarray = env->NewByteArray(pAdapter->AddressLength);

env->SetByteArrayRegion(jarray, 0, pAdapter->AddressLength, pAdapter->Address);

env->CallVoidMethod(NetDataClassObject, setAddress, jarray);

SetByteArrayRegion' : cannot convert parameter 4 from 'unsigned char [8]' to 'const signed char *'

if I cast pAdapter->Address with (const signed char*) in java I get weirds characters...

here the reference to c++ structs

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_addr_string.asp

Any help? Thanks for attention,

Alessandro

[847 byte] By [opiua] at [2007-10-2 23:46:04]
# 1
no clues?Alessandro
opiua at 2007-7-14 16:30:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Actually I was doing good :-), the cast is right but then when i receive the byte[] in Java I have to convert byte values to hexadecimal equivalent to see same values i print in C++. Here the code:

[c++]

jbyteArray jarray = env->NewByteArray(pAdapter->AddressLength);

env->SetByteArrayRegion(jarray, 0, pAdapter->AddressLength, (const signed char*)pAdapter->Address);

env->CallVoidMethod(NetDataClassObject, setAddress, jarray);

[java]

public static String byteToHex(byte b){

int i = b & 0xFF;

return Integer.toHexString(i);

}

bye, Alessandro

opiua at 2007-7-14 16:30:33 > top of Java-index,Java HotSpot Virtual Machine,Specifications...