[foreign] RFR: add binder support for panama array carriers

Henry Jen henry.jen at oracle.com
Fri May 25 18:58:49 UTC 2018


Looks good, just curious, why static method in BoundedArray instead of default method on Array?

Cheers,
Henry


> On May 25, 2018, at 11:13 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> And this is another iteration which turns BoundedArray::copyTo/From into static methods
> 
> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier-v3/
> 
> Maurizio
> 
> 
> On 25/05/18 18:35, Maurizio Cimadamore wrote:
>> Slightly updated webrev which hoists the MH creation in BoundedArray::copyTo/From
>> 
>> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier-v2/
>> 
>> Maurizio
>> 
>> 
>> On 25/05/18 18:26, Maurizio Cimadamore wrote:
>>> Hi,
>>> this patch removes binder support for Java array carriers and rewrires array support to use the Panama Array class.
>>> 
>>> To allow interop from Java arrays and back the following API points have been added:
>>> 
>>> Array<Integer> nativeArray = ...
>>> int[] ia = nativeArray.toArray(int[]::new);
>>> 
>>> And, the reverse operation is handled by Scope, by having a form of native array allocation which takes a Java array initializer:
>>> 
>>> Array<Integer> newNativeArray = scope.allocateArray(NativeTypes.INT32, ia);
>>> 
>>> This seems to work pretty well in terms of usability. Under the hood, the methods BoundedArray::copyFrom/To use MethodHandles to avoid boxing of elements.
>>> 
>>> I've removed a lot of code that had to do, directly or indirectly, with Java array accessors generated by the binder.
>>> 
>>> Webrev:
>>> 
>>> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier/
>>> 
>>> Cheers
>>> Maurizio
>>> 
>>> 
>> 
> 



More information about the panama-dev mailing list