RFR: 8347408: Create an internal method handle adapter for system calls with errno

Per Minborg pminborg at openjdk.org
Mon May 5 16:59:02 UTC 2025


As we advance, converting older JDK code to use the relatively new FFM API requires system calls that can provide `errno` and the likes to explicitly allocate a MemorySegment to capture potential error states. This can lead to negative performance implications if not designed carefully and also introduces unnecessary code complexity.

Hence, this PR proposes adding a JDK internal method handle adapter that can be used to handle system calls with `errno`, `GetLastError`, and `WSAGetLastError`.

It relies on an efficient carrier-thread-local cache of memory regions to allide allocations.

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

Commit messages:
 - Use stable values
 - Merge branch 'master' into errno-util3b
 - Add hashCode/equals to record to improve startup time
 - Revert change to ArenaImpl
 - Merge master
 - Merge master
 - Add test for woven allocation
 - Merge branch 'master' into errno-util3
 - Use lazy initialization of method handles
 - Clean up visibility
 - ... and 29 more: https://git.openjdk.org/jdk/compare/1501a5e4...04dc6d3e

Changes: https://git.openjdk.org/jdk/pull/25043/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25043&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347408
  Stats: 818 lines in 9 files changed: 805 ins; 0 del; 13 mod
  Patch: https://git.openjdk.org/jdk/pull/25043.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25043/head:pull/25043

PR: https://git.openjdk.org/jdk/pull/25043


More information about the core-libs-dev mailing list