On Wed, 25 Nov 2026 16:23:59 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).

src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java
 line 183:

> 181:             // always long in the underlying system.
> 182:             int out = (int) MH_getpwuid_r.invoke(
> 183:                     tmpUid, pwd, buffer, GETPW_R_SIZE_MAX, result);

It's generally better to use `invokeExact`, since that can be inlined by the 
JIT, while `invoke` can not (unless the call site type already matches the MH 
type exactly, but in that case we might just as well use `invokeExact`).

It's possible to use `invokeExact` here by erasing the type of the method 
handle beforehand, e.g. with a call to `asType(MethodType.methodType(int.class, 
int.class, MemorySegment.class, MemorySegment.class, int.class, 
MemorySegment.class))`. On platforms where the 4th parameter is `int` this 
would be a no-op, on other platforms it would be widened to `long` internally 
inside the methodhandle.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/34071#discussion_r4711160568

Reply via email to