Migrate from JNA to jnr-posix for native POSIX operations#271
Merged
Conversation
Replace JNA 5.18.1 (which uses deprecated sun.misc.Unsafe::staticFieldBase)
with jnr-posix 3.1.19 for POSIX operations and pure Java APIs for Windows.
- PosixLibrary: rewritten as thin wrapper around POSIXFactory.getNativePOSIX()
- WindowsLibrary: gutted (was entirely unused)
- NativeUtils: Windows kill uses ProcessHandle.destroy(), platform detection
via System.getProperty("os.name") instead of JNA Platform class
- ExtendedNativeUtils: uses jnr.posix.Passwd instead of raw Pointer parsing
- Stat: uses jnr.posix.FileStat instead of Memory/Pointer parsing
- KillOperator: Windows uses ProcessHandle, POSIX uses jnr-posix kill+errno
- UtimeOperator: POSIX uses jnr-posix utimes(), Windows uses pure Java NIO
- WaitpidOperator: Windows uses Process/ProcessHandle, POSIX uses int[]
- Operator: Windows chmod uses Files.setAttribute("dos:readonly")
- Removed 19 unused PosixLibrary method declarations (fork, execve, etc.)
- Removed dead registerWindowsChildProcess code
- Added --enable-native-access=ALL-UNNAMED to jperl.bat
Net: -1052 lines, +211 lines across 15 files. All existing tests pass.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sun.misc.Unsafe::staticFieldBase) with jnr-posix 3.1.19 for POSIX operations and pure Java APIs for Windowsjnaandjna-platformdependenciesKey changes
POSIXFactory.getNativePOSIX()ProcessHandle.destroy(), platform detection viaSystem.getProperty("os.name")instead of JNAPlatformclassjnr.posix.Passwdinstead of rawPointerparsingjnr.posix.FileStatinstead ofMemory/PointerparsingProcessHandle, POSIX uses jnr-posixkill()+errno()utimes(), Windows uses pure Java NIOProcess/ProcessHandle, POSIX usesint[]chmodusesFiles.setAttribute("dos:readonly", ...)PosixLibrarymethod declarations (fork, execve, signal, etc.)registerWindowsChildProcesscode--enable-native-access=ALL-UNNAMEDtojperl.batTest plan
./gradlew buildpasses (unit tests)make testpassesmake test-all— 45.2% pass rate consistent with pre-existing baseline, no regressions from migrationstat_errors.t(638/638),io/fs.t(53/61),fork.t,waitpid.t,glob.t(17/18),kill0.t(6/9)com.sun.jnaremain in codebaseGenerated with Devin