RFR: 7903628: Replace ofAddress method in FI classes with a static invoke method

Jorn Vernee jvernee at openjdk.org
Tue Jan 16 16:05:21 UTC 2024


This patch replaces the factory method in the generated function pointer interfaces with a static invoke method. This avoids clients having to wrap a function pointer in an instance of the interface in order to invoke it, and instead allows invoking function pointers more directly. This aligns with the general jextract strategy of being 'all static' which avoids object allocation overheads.

The new approach also simplifies the handling of function pointers that accept an allocator (because they return a struct by-value), as now we no longer how to infer the allocator, but the client can pass it explicitly when invoking the function pointer.

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

Commit messages:
 - replace FI ofAddress factory with static invoke method

Changes: https://git.openjdk.org/jextract/pull/180/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=180&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903628
  Stats: 27 lines in 4 files changed: 2 ins; 4 del; 21 mod
  Patch: https://git.openjdk.org/jextract/pull/180.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/180/head:pull/180

PR: https://git.openjdk.org/jextract/pull/180


More information about the jextract-dev mailing list