CLinker migration from jdk17 to jdk18
Lev Serebryakov
lev at serebryakov.spb.ru
Tue Apr 5 14:54:18 UTC 2022
On 05.04.2022 17:32, Maurizio Cimadamore wrote:
Thank you for quick answer!
My comments are in-line.
> Or, you can define alias for C types in your platform if you want (jextract will do that).
So, no platform independence in client code anymore?
In JDK17 all these C_XXX were picked by Panama for me, and I was sure, that if there is platform unknown to me, JDK on this platform Will Do Right Thing.
What should I do now to write universal code, which will work on all platforms, known and unknown to me?
>
> So, in short, your example will become something like:
>
> ```
> h_native = CLinker.systemCLinker()
> .downcallHandle(
> libLookup.lookup("somefunc").get(),
> FunctionDescriptor.of(
> ValueLayout.ADDRESS,
> ValueLayout.JAVA_INT,
> ValueLayout.ADDRESS,
> ValueLayout.ADDRESS,
> ValueLayout.JAVA_INT,
> ValueLayout.JAVA_INT
> )
> );
> ```
>
> (the above assumes LP64 - e.g. where a C int is 32 bits).
I don't like assumptions in my (client) code, as JDK can be ported to other platforms I know nothing about. JDK porters, though, know proper mapping for their platform.
--
// Black Lion AKA Lev Serebryakov
More information about the panama-dev
mailing list