Implement no copy memory
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue May 21 08:14:49 UTC 2019
On 21/05/2019 05:26, Ardika Rommy Sanjaya wrote:
> If using panama should I cast the Pointer<Byte> before get the content
> data?
In Panama you would do this:
Pointer<Byte> buf = ...
Pointer<Short> ps = buf.cast(NativeTypes.VOID).cast(NativeTypes.UINT16);
short s = ps.get();
or...
Pointer<Integer> pi = buf.cast(NativeTypes.VOID).cast(NativeTypes.UINT32);
int i = pi.get();
Note that you have to cast through VOID first, otherwise the Panama
runtime will complain about incompatible cast.
I believe we can relax these rules for cast compatibility a bit - we
have some ideas in mind there [1].
[1] -
https://mail.openjdk.java.net/pipermail/panama-dev/2019-February/004665.html
>
> For example if I want to get 2 byte and then 4 byte with Unsafe I can
> do like below:
>
> Unsafe UNSAFE = ...
>
> UNSAFE.getShort(..)
> UNSAFE.getInt(...)
>
More information about the panama-dev
mailing list