[foreign-jextract] RFR: 8274155 Foreign API refresh - jextract update

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Sep 22 15:48:54 UTC 2021


These are the jextract changes for the recent refresh of the Foreign Memory Access/Foreign Linker API. The biggest change in this API refresh comes from the removal of layout attributes. Jextract used to store several information in the form of layouts attributes. After some analysis, it turned out that in all cases, the use of layout attributes was not necessary, and it was really driven by the fact that jextract was, in certain places, using `MemoryLayout` as its main internal representation, instead of using the more flexible `Declaration`/`Type` APIs. Unfortunately, updating `RecordLayoutComputer` to work on `Declaration` rather than `MemoryLayout` caused changes in several part of the jextract parsing frontend.

Other minor changes were required, to adjust jextract to the new API changes - but most of these are small. I've dropped several now redundant overloads (so the size of the generated bindings should be smaller). There's also an additional piece of code which is used to emit typedef for common C primitive types such as `C_INT` and the likes (since the layouts for these are no longer in `CLinker`).

The test changes are mostly trivial updates to use the new API.

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

Commit messages:
 - Remove commented lines
 - Merge branch 'foreign-jextract' into foreign-finalize+jextract
 - Tweak test after removal of MemoryAddress::freeMemory
 - Add/fix copyright headers
 - * Add scope check to UpcallStub::address
 - * Add implNote on `ResourceScope#keepAlive` documenting the maximum number of keep alive requests
 - * Drop more unused imports
 - Fix javadoc for `MemoryAddress::setUtf8String`
 - Drop `MemoryAddress::freeMemory`/`MemoryAddress::allocateMemory` leftovers
 - Clarify javadoc of indexed getters/setters in `MemorySegment`/`MemoryAddress`
 - ... and 5 more: https://git.openjdk.java.net/panama-foreign/compare/1ac1abfd...9976b842

Changes: https://git.openjdk.java.net/panama-foreign/pull/577/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=577&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8274155
  Stats: 1545 lines in 80 files changed: 518 ins; 675 del; 352 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/577.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/577/head:pull/577

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


More information about the panama-dev mailing list