RFR: 7903947: Access to function pointers in structs could be streamlined
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jul 25 15:17:13 UTC 2025
On Fri, 25 Jul 2025 09:27:13 GMT, Duncan Gittins <duncan.gittins at gmail.com> wrote:
> Now I think about it, renaming the invoker may be necessary after all.
> The setter would be useful for applications to fill struct with Java
> upcalls to implement callbacks. eg implementing COM api, rather than using
> one.
Thanks, this is an useful data point. If it turns out that our assumption that "these structs only need invokers" is not 100% true, that doesn't leave us in a good place. While you could refrain from using the new flag on your struct, it feels like a "glass half empty" situation, because the code jextract would be able to generate is _almost there_.
Which brings us back to another option: maybe the more honest option is to indeed add an invoker-like accessor for each function pointer field (e.g. Foo.m$invoke). The dollar in the same sucks a bit but, oh well, at least it's clear.
Then, let's approach this from the other angle, and give developer more options to NOT generate stuff they don't want. E.g. maybe this struct is read-only and doesn't need setters? Or maybe it's invoke-only and doesn't need neither getters nor setters? Whatever the needs, and whatever the reason, we'd have a way to generate, more or less, only the stuff one would be interested in.
So, maybe, instead of "functional struct", maybe some way to say what you want in a struct -- similar to Linux filesystem `rwx` (read/write/execute) :-)
-------------
PR Comment: https://git.openjdk.org/jextract/pull/287#issuecomment-3118491817
More information about the jextract-dev
mailing list