New candidate JEP: 412: Foreign Function & Memory API (Incubator)
Gerard Ziemski
gerard.ziemski at oracle.com
Thu Apr 22 21:42:56 UTC 2021
hi,
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?
cheers
> On Apr 22, 2021, at 1:27 PM, mark.reinhold at oracle.com wrote:
>
> https://openjdk.java.net/jeps/412
>
> Summary: Introduce an API by which Java programs can interoperate with
> code and data outside of the Java runtime. By efficiently invoking
> foreign functions (i.e., code outside the JVM), and by safely accessing
> foreign memory (i.e., memory not managed by the JVM), the API enables
> Java programs to call native libraries and process native data without
> the brittleness and danger of JNI.
>
> - Mark
More information about the panama-dev
mailing list