On Thu, 26 Nov 2026 17:41:16 GMT, Martin Doerr <[email protected]> wrote:
>> We should use sign information >> ([JDK-8336664](https://bugs.openjdk.org/browse/JDK-8336664)) and replace the >> long conversion workaround for ppc64 and s390 >> (https://github.com/openjdk/jdk/pull/28931/changes/99604e06a1b5055f5d20c26de7dff8203ea17762). >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Martin Doerr has updated the pull request incrementally with one additional > commit since the last revision: > > Remove outdated comment + minor cleanup. I like this optimization even if performance is not so important: diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java index 0d07e73c3ad..4607f451401 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java @@ -100,10 +100,10 @@ public class UnixSystem { private static final MethodHandle MH_getgroups = LINKER.downcallHandle(SYMBOL_LOOKUP.findOrThrow("getgroups"), FunctionDescriptor.of(C_INT, C_INT, C_POINTER), - Linker.Option.captureCallState("errno")); + Linker.Option.captureCallState("errno"), Linker.Option.critical(true)); private static final MethodHandle MH_getuid = LINKER.downcallHandle(SYMBOL_LOOKUP.findOrThrow("getuid"), - FunctionDescriptor.of(C_INT)); + FunctionDescriptor.of(C_INT), Linker.Option.critical(false)); // getpwuid_r does not work on AIX, instead we use another similar function // extern int _posix_getpwuid_r(uid_t, struct passwd *, char *, int, struct passwd **) @@ -163,8 +163,9 @@ public UnixSystem() { throw new RuntimeException("getgroups returns " + groupnum); } - var gs = scope.allocate(C_INT, groupnum); - groupnum = (int) MH_getgroups.invokeExact(capturedState, groupnum, gs); + var grouparray = new int[groupnum]; + groupnum = (int) MH_getgroups.invokeExact(capturedState, groupnum, + MemorySegment.ofArray(grouparray)); if (groupnum == -1) { var errno = (int) VH_errno.get(capturedState, 0L); var errMsg = (MemorySegment) MH_strerror.invokeExact(errno); @@ -174,7 +175,7 @@ public UnixSystem() { groups = new long[groupnum]; for (int i = 0; i < groupnum; i++) { - groups[i] = Integer.toUnsignedLong(gs.getAtIndex(C_INT, i)); + groups[i] = Integer.toUnsignedLong(grouparray[i]); } var pwd = scope.allocate(ML_passwd); Would anybody want to have it? ------------- PR Comment: https://git.openjdk.org/jdk/pull/34071#issuecomment-7202826576
