fb64 opened a new pull request, #1334:
URL: https://github.com/apache/arrow-java/pull/1334

   ## What's Changed
   
   `MemoryUtil` relies on `sun.misc.Unsafe` whichever allocation manager is 
used, and on reflection that requires 
`--add-opens=java.base/java.nio=ALL-UNNAMED`. Unsafe memory access is 
deprecated for removal (JEP 471) and has printed a warning since JDK 24 (JEP 
498). This PR adds an opt-in alternative built on the FFM API, which is final 
since JDK 22 (JEP 454).
   
   - **Refactoring, no behavior change:** the Unsafe code in `MemoryUtil` moves 
to `UnsafeMemoryAccessor`, behind a new `MemoryUtilAccessor` interface. Unsafe 
stays the default.
   - **New `arrow-memory-ffm` module (JDK 22+):** `FfmMemoryAccessor` uses 
`MemorySegment`/`Arena` instead of Unsafe and reflection, and 
`FfmAllocationManager` allocates one `Arena` per buffer. The module is only 
built with a JDK 22+ launcher. It's added to the BOM and the docs.
   - **Opt-in:** `-Darrow.allocation.manager.type=FFM` switches both the 
allocator and the accessor, so Unsafe isn't used at all. 
`-Darrow.memory.accessor.type=FFM` switches only the accessor.
   
   With FFM, `--add-opens` is no longer needed, and a dedicated test run checks 
that. `MemorySegment.reinterpret` is a restricted method, so pass 
`--enable-native-access=org.apache.arrow.memory.ffm` (or `ALL-UNNAMED` on the 
classpath) to avoid a JVM warning.
   
   I assume this request was created with the help of AI agent (Claude).
   
   Closes #163.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to