RFR: 8277924: Small tweaks to foreign function and memory API [v3]
Paul Sandoz
psandoz at openjdk.java.net
Tue Nov 30 18:57:07 UTC 2021
On Tue, 30 Nov 2021 13:20:32 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Following integration of the second incubator of the foreign function and memory API [1], we detected few divergences between the contents of the jdk repo and the panama repo:
>>
>> * the name of some of the `FunctionDescriptor` wither methods is different (e.g. `withAppendedLayoutArguments` vs. `appendLayoutArguments`), as it has been simplified and improved following a change that was not incorporated in [1].
>>
>> * TestUpcall does not execute all the test combinations, because of an issue in the jtreg header (also fixed in the panama repo)
>>
>> * Addressing some feedback, we would like to bring back alignment to JAVA_INT layout constants (and related constants).
>>
>> Javadoc: http://cr.openjdk.java.net/~mcimadamore/8277924/v1/javadoc/jdk/incubator/foreign/package-summary.html
>> Specdiff: http://cr.openjdk.java.net/~mcimadamore/8277924/v1/spec_diff/overview-summary.html
>>
>> [1] - #5907
>
> Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision:
>
> - Drop changes to alignment of layout constants
> - Simplify logic to access package-private method in ValueLayout
Marked as reviewed by psandoz (Reviewer).
src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/FunctionDescriptor.java line 140:
> 138: public FunctionDescriptor insertArgumentLayouts(int index, MemoryLayout... addedLayouts) {
> 139: Objects.requireNonNull(addedLayouts);
> 140: Arrays.stream(addedLayouts).forEach(Objects::requireNonNull);
FWIW you can remove this line if you wish, since the `List.of()` will check for null elements. You could replace lines 139 to 143 with:
if (index < 0 || index > argLayouts.size())
throw new IllegalArgumentException("Index out of bounds: " + index);
List<MemoryLayout> added = List.of(addedLayouts); // null check on array and its elements
List<MemoryLayout> newLayouts = new ArrayList<>(argLayouts.size() + added.size());
-------------
PR: https://git.openjdk.java.net/jdk/pull/6589
More information about the core-libs-dev
mailing list