RFR: 8360025: (se) Convert kqueue Selector Implementation to use FFM APIs
Andrey Turbanov
aturbanov at openjdk.org
Wed Oct 15 08:32:50 UTC 2025
On Tue, 14 Oct 2025 10:38:01 GMT, Darragh Clarke <dclarke at openjdk.org> wrote:
> This PR was originally part of #25546, though that PR has been split in 2, the first chunk was https://github.com/openjdk/jdk/pull/27590.
>
> This PR aims to convert KQueue to use FFM apis, the first PR in this area added all the jextract generated code needed, while this PR modifies some of the jextract code and then uses it with Kqueue.
>
> A brief rundown of the changes:
> - The files `errno_h$shared.java` , `kqueue_h$shared.java`, `timespec_h$shared.java` and `timespec_h.java` have all been deleted. This is because they all contained shared elements that could be moved into the Utility file `FFMUtils.java`
> - `Kqueue.c` has been deleted, and all native methods in the other `KQueue` files have been replaced with references to the generated files kevent and kqueue. This is the bulk of the changes
> - Both the `Kqueue()` and `Kevent()` methods in `kqueue_h.java` were modified to use adapted method handles that will return the errno value
src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java line 154:
> 152: public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC,
> 153: Linker.Option.captureCallState(ERRNO_NAME));
> 154: public static final MethodHandle ADAPTED = CaptureStateUtil.adaptSystemCall(HANDLE, ERRNO_NAME);
Suggestion:
public static final MethodHandle ADAPTED = CaptureStateUtil.adaptSystemCall(HANDLE, ERRNO_NAME);
src/java.base/macosx/classes/sun/nio/ch/KQueue.java line 134:
> 132: }
> 133:
> 134: static public int poll(int kqfd, MemorySegment pollAddress, int nevents, long timeout) {
Let's use blessed modifiers order
Suggestion:
public static int poll(int kqfd, MemorySegment pollAddress, int nevents, long timeout) {
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27796#discussion_r2431609571
PR Review Comment: https://git.openjdk.org/jdk/pull/27796#discussion_r2431612250
More information about the nio-dev
mailing list