[foreign-abi] RFR: 8248499: Add methods to allocate off heap arrays from Java arrays

Athijegannathan Sundararajan sundar at openjdk.java.net
Tue Jun 30 09:58:03 UTC 2020


On Tue, 30 Jun 2020 03:19:14 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

>> This patch adds methods to NativeScope which allow clients to allocate off-heap arrays from Java on-heap arrays.
>> 
>> While in most cases the code for copying is straightforward, we have to take into account endianness mismatches (in
>> case the user wants to store the array elements off-heap in an endianness that doesn't match that of the platform).
>> To allow for that, I've added a new implementation method in AbstractMemorySegmentImpl, which is the same as
>> `copyFrom`, but adds the byte swap (a wrapper around `Unsafe::copySwapMemory`).
>
> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/NativeScope.java line 56:
> 
>> 55:     Unsafe unsafe = Unsafe.getUnsafe();
>> 56:
>> 57:     /**
> 
> should this field be private?

looks like unused. may be removed

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

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


More information about the panama-dev mailing list