[foreign-memaccess] RFR: 8248487: Add static helpers to access segments [v3]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Jul 1 10:39:33 UTC 2020


On Tue, 30 Jun 2020 11:22:47 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Update src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java
>>   
>>   Co-authored-by: Henry Jen <henryjen at ztune.net>
>
> test/jdk/java/foreign/TestByteBuffer.java line 630:
> 
>> 629:         Consumer<MemoryAddress> doubleInitializer =
>> 630:                 (base) -> initBytes(base, doubles, (addr, pos) -> MemoryLayouts.setDouble_BE(addr, pos * 8,
>> (double)(long)pos)); 631:
> 
> Seems strange to me to switch to MemoryLayout.setXXX here, since we are actually accessing an element of a known
> layout, instead of a one-off value.
> As a result, you now have to multiply the offset with a magic number that represents the stride. I don't think this is
> a good use-case...

most of our tests are like that (at least in the memory access domain - ABI tests are different). I just wanted at
least _one_ test to use the accessor, and TestByteBuffer is one of the tests we have which is complex enough to provide
good coverage for the accessors.

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/221


More information about the panama-dev mailing list