[foreign-memaccess] RFR: 8248487: Add static helpers to access segments [v2]
Henry Jen
henryjen at openjdk.java.net
Tue Jun 30 21:56:00 UTC 2020
On Tue, 30 Jun 2020 19:00:18 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch addresses some usability issues in the foreign memory API. First, it adds several static accessors for all
>> carrier types in MemoryLayouts (I'm thorn whether to add this in MemoryLayouts or MemoryHandles, suggestions welcome).
>> These accessors provide an access API that is similar to unsafe - all accessors expect a base address plus a byte
>> offset. In most cases the accessors can be used and direct VH usage can be dropped, which might make approaching this
>> API a bit easier. Secondly, I've added a bunch of helpers to map a segment into _any_ array (as opposed to just
>> `byte[]`). This makes the API more symmetric, given that, after all we _were_ able to create a segment from _any_ array
>> (not just `byte[]`).
>
> Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision:
>
> - Add javadoc, and make the class final
> - Move accessors to separate class called MemoryAccess
Marked as reviewed by henryjen (Committer).
src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java line 29:
> 28:
> 29: import java.lang.invoke.VarHandle;
> 30: import java.nio.ByteOrder;
Suggestion:
src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java line 139:
> 138: public static final ValueLayout JAVA_DOUBLE = MemoryLayout.ofValueBits(64, ByteOrder.nativeOrder());
> 139:
> 140: }
Suggestion:
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/221
More information about the panama-dev
mailing list