[foreign-memaccess+abi] RFR: 8307253: Make FunctionDescriptor::toMethodType an instance method of Linker [v3]

Jorn Vernee jvernee at openjdk.org
Mon May 8 13:06:54 UTC 2023


On Fri, 5 May 2023 15:17:57 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This patch moves `FunctionDescriptor::toMethodType` as an instance method of `Linker`. This allows linker implementations to be more opinionated on how the function descriptor -> method type conversion should behave.
>
> Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains four commits:
> 
>  - Address review comments (check for padding during function descriptor construction)
>  - Merge branch 'foreign-memaccess+abi' into toMethodType
>  - Revert changes.
>    Fix javadoc and impl for FunctionDescriptor::toMethodType to allow sequence layouts.
>  - Initial push

Nice! Couple of minor comments.

src/java.base/share/classes/jdk/internal/foreign/FunctionDescriptorImpl.java line 55:

> 53:             throw new IllegalArgumentException("Unsupported padding layout return in function descriptor: " + resLayout);
> 54:         }
> 55:         Optional<MemoryLayout> paddingLayout = argLayouts.stream().filter(l -> l instanceof PaddingLayout).findAny();

This could use `Stream::anyMatch`.

test/jdk/java/foreign/TestFunctionDescriptor.java line 152:

> 150:     public void testBadPaddingInNonVoidFunction() {
> 151:         FunctionDescriptor.ofVoid(MemoryLayout.paddingLayout(8));
> 152:     }

This test is the same as the one above. Looks like you meant to call `of` here? (instead of `ofVoid`)

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

Marked as reviewed by jvernee (Committer).

PR Review: https://git.openjdk.org/panama-foreign/pull/830#pullrequestreview-1416754752
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/830#discussion_r1187418631
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/830#discussion_r1187421056


More information about the panama-dev mailing list