CLinker migration from jdk17 to jdk18
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Apr 5 15:10:54 UTC 2022
On 05/04/2022 16:08, Lev Serebryakov wrote:
> On 05.04.2022 17:32, Maurizio Cimadamore wrote:
>
> BTW, I get "java.lang.invoke.WrongMethodTypeException" when call
> invokeExact() resulting handle on JDK18/Windows.
>
> Previous code works well on JDK17.
Please past callsite code. You are probably missing some casts to
Addressable in by-ref parameters.
The tutorial previously linked (as well as the CLinker API javadoc)
covers this.
Maurizio
>
>> 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).
>
More information about the panama-dev
mailing list