Weird behaviour of Java MethodHandle.invokeExact Here is a minimal working example (requires Java 22 or later):