RFR: 7903947: Access to function pointers in structs could be streamlined

Nizar Benalla nbenalla at openjdk.org
Mon Jul 28 13:50:14 UTC 2025


On Wed, 23 Jul 2025 12:37:47 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

> Please review this patch to add a new option where you can generate an direct invoker methods. This feature is intended to be used on structs that are just a collection of functions we had like to call.
> 
> If this feature is used, we remove the getter to avoid name collisions as we assume this is similar to an interface.
> 
> Changes to `GUIDE.md` have been intentionally left out from this initial patch to make reviews easier.
> 
> 
> struct Foo {
>     struct Bar (*a)(void);
>     struct Bar (*b)(int);
> };
> 
> 
> Before 
> 
> 
> var foo = alloc_callback_h.foo();
> 
> var barA = Foo.a.invoke(Foo.a(foo), arena);
> var barB = Foo.b.invoke(Foo.b(foo), arena, 100);
> 
> 
> After 
> 
> 
> var foo = alloc_callback_h.foo();
> 
> var barA = Foo.a(foo, arena);
> var barB = Foo.b(foo, arena, 100);

I kept trying to avoid renaming the invoker as I didn't like having the dollar sign or a prefix in the invoker, but I like the idea of having readonly/write/execute mode in the config.

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

PR Comment: https://git.openjdk.org/jextract/pull/287#issuecomment-3127329675


More information about the jextract-dev mailing list