[foreign-jextract] RFR: 8241925: jextract should generate simple allocation, access API for C primitive types

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Mar 31 16:11:08 UTC 2020


On Tue, 31 Mar 2020 16:05:42 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> added static method helper classes to handle allocation, access ot C primitive types and C strings.
>
> Some examples still use Foreign.toCString - I think we should remove those helpers from Foreign to avoid confusion.

General comment and context; the idea is that, moving forward, jextract will emit a lot of those helper interfaces -
this patch covers primitives, but we'll add support for typedeffed types as well as structs. This will make interacting
with native code a lot easier, and remove a lot of the guessing around "which carrier should I use when I see a
`size_t`".  The generated helpers are still pretty lean, just static methods in them - this allows the client code to
be type-safe w/o compromising performances and/or adding extra layers of indirection/boxing.

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

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


More information about the panama-dev mailing list