RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles

Claes Redestad redestad at openjdk.java.net
Fri May 27 14:41:45 UTC 2022


On Fri, 27 May 2022 14:18:19 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> In preparation of #8855 this PR refactors the conversions from `List` to array and array to `List`, reducing the number of conversions when calling `MethodHandles.dropArguments` in particular. This remove about ~5% of allocations on the `StringConcatFactoryBootstraps` microbenchmark.

It might be a bit too paranoid in this instance (since we don't keep the array around for long), but not cloning the result of calling `toArray` on an arbitrary and possibly adversary `List` could open up for TOCTOU race bugs / attacks. The existing code was being paranoid and copying and I don't want to weaken something that could have security implications without double- and triple-checking that it's safe to do so.

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

PR: https://git.openjdk.java.net/jdk/pull/8923


More information about the core-libs-dev mailing list