[foreign-jextract] RFR: 8276136: functional interface extraction broken after API refresh

Jorn Vernee jvernee at openjdk.java.net
Fri Oct 29 12:20:34 UTC 2021


On Thu, 28 Oct 2021 22:32:18 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This addresses the issue discovered in this thread:
> 
> https://mail.openjdk.java.net/pipermail/panama-dev/2021-September/015144.html
> 
> The issue is causes by the fact that the new linker changes introduce an asymmetry between the method type of the downcall and that of an upcall. Downcall have `Addressable` for parameters passed by-reference, and `MemoryAddress` for by-reference returns. Upcalls adopt the dual scheme (`MemoryAddress` for parameters, `Addressable` for return values).
> 
> This patch bridges the two schemes by inserting the required casts which keep `invokeExact` happy in the case where we generate a functional interface implementation which calls the upcall stub address.
> 
> To do that I had to dig a bit in `TypeTranslator` to make the type translation context-dependent. I also had to enhance `FunctionInfo` so that it could carry the "reverse" method type in the upcall case.
> 
> I've added a test which checks a function pointer which takes an address and returns another address - which stresses both argument and return mismatch.

LGTM

-------------

Marked as reviewed by jvernee (Committer).

PR: https://git.openjdk.java.net/panama-foreign/pull/605


More information about the panama-dev mailing list