[foreign-preview] RFR: 8286306: Upcall wrapper class sharing
Jorn Vernee
jvernee at openjdk.java.net
Fri May 6 16:12:08 UTC 2022
On Fri, 6 May 2022 16:06:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 215:
>>
>>> 213: // adjust return type so it matches the inferred type of the effective
>>> 214: // function descriptor
>>> 215: target = target.asType(target.type().changeReturnType(Addressable.class));
>>
>> Note that this is needed to prevent a situation on Windows where the effective function descriptor of `()[<some IMR struct>]` is the same as a plain `(a64)a64` function descriptor. The `target` will currently have the type `(MemoryAddress)MemoryAddress` in the former case, but `(MemoryAddress)Addressable` in the latter case. However, they share an upcall wrapper class because they have the same effective function descriptor (which is good), and this leads to a `WrongMethodTypeException` when invoking one of them.
>
> I think you mean in the latter case is `(Addressable)MemoryAddress` ?
No, for upcalls it is `(MemoryAddress)Addressable` i.e. the return type is changed.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/679
More information about the panama-dev
mailing list