New candidate JEP: 412: Foreign Function & Memory API (Incubator)

Alex Buckley alex.buckley at oracle.com
Thu Apr 22 22:04:19 UTC 2021


On 4/22/2021 2:42 PM, Gerard Ziemski wrote:
> I read this JEP only once so far, but one thing that I immediately noticed was whether MethodType is really necessary when constructing a MethodHandle, or whether that info can be inferred from FunctionDescriptor as in this given example:
> 
> 
> MethodHandle qsort = CLinker.getInstance().downcallHandle(
>          LibraryLookup.ofDefault().lookup("qsort").get(),
>          MethodType.methodType(void.class, MemoryAddress.class, long.class,
>                                long.class, MemoryAddress.class),
>          FunctionDescriptor.ofVoid(C_POINTER, C_LONG, C_LONG, C_POINTER)
> );
> 
> Seems to me that FunctionDescriptor and MethodType describe the same layout?

Please review the section "Describing C types in Java": 
https://openjdk.java.net/jeps/412#Describing-C-types-in-Java

It describes how the MethodType relates to the FunctionDescriptor. The 
interesting case is the final example, regarding structured data.

Alex


More information about the jdk-dev mailing list