I am trying to allocate memory using sun.misc.Unsafe.allocateMemory () and access it in native code.
however, it seems that the long value returned by allocateMemory does not quite work as the right address in the C code.
Unsafe unsafe = getUnsafe(); long address = unsafe.allocateMemory(64); for (int i = 0; i < 64; i += 8) unsafe.putByte(memory + i, (byte) 0xFF); nativeMethod(address);
However, in my native code, when I try to access the "address" as a pointer, it does not work :(
Update:. I added an image showing this problem. I passed the "address" to the native code, however, checking the memory in this place does not show the 0xFF value that I put there.
Image: http://i.stack.imgur.com/KoIYG.png

source share