[foreign-memacces] RFR 8224993: Add Unsafe support for MemoryAddress
Jorn Vernee
jbvernee at xs4all.nl
Wed May 29 17:31:51 UTC 2019
Hi,
This looks good!
But, there's 1 conversion from a jlong to a jint in libNativeAccess.c,
which causes a warning, which then causes an error when building (due to
-Werror). The conversion happens in Java_TestNative_getCapacity. Note
that GetDirectBufferCapacity returns a jlong.
After changing the return type of Java_TestNative_getCapacity to
jlong/long as well I'm seeing all tests green.
Cheers,
Jorn
Maurizio Cimadamore schreef op 2019-05-29 18:17:
> Hi,
> after adding byte buffer interop support, I think it's worth looking
> at another avenue of migration - that is, translating a MemoryAddress
> into a base/offset coordinate pair, used by the Unsafe class.
>
> http://cr.openjdk.java.net/~mcimadamore/panama/8224993/
>
> In addition to add the trivial Unsafe capabilities, this patch also
> fixes some issues that were left unaddressed after the addition of
> ByteBuffer support - more specifically, the wrapped 'scoped' buffers
> do not have the 'address' , 'hb' and the 'capacity' fields set -
> unfortunately, these fields are accessed in a raw fashion to implement
> JNI functionalites such as GetDirectBufferAddress and
> GetDirectBufferCapacity.
>
> I've also removed the bit-swapping from the
> VarHandleMemoryAddressAsBytes class - after all, NativeOrder deals
> with _byte_ swapping, so there's nothing meaningful we can do at the
> byte level (and that's also consistent with what ByteBuffer does).
>
> Cheers
> Maurizio
More information about the panama-dev
mailing list