On Fri, 13 May 2022 11:17:20 GMT, Jorn Vernee <jver...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/abi/ProgrammableInvoker.java >> line 215: >> >>> 213: for (int i = 0; i < highLevelType.parameterCount(); i++) { >>> 214: List<Binding> bindings = >>> callingSequence.argumentBindings(i); >>> 215: argInsertPos += >>> Math.toIntExact(bindings.stream().filter(Binding.VMStore.class::isInstance).count()) >>> + 1; >> >> My gut feeling in this case would be that it's a bit strange to use >> `Math.toIntExact` to do a safe cast when you don't do `Math.addExact` to >> ensure that the result of the addition will not overflow. I wonder if a >> simple cast wouldn't be more appropriate - unless you really think that you >> might have more than Integer.MAX_VALUE bindings (which I doubt :-) ). But >> that's just my feeling... > > Yeah, that's true. I don't really expect this to ever overflow, that would > create issues in other cases as well (since the limit on argument count is > 255 for instance). > > Okay, I'll switch this to a regular cast. (It doesn't matter too much I think > because I'm also planning to remove this code: > https://github.com/openjdk/jdk/pull/8685) Fixed. ------------- PR: https://git.openjdk.java.net/jdk/pull/8697