This patch migrates `MethodHandles::arrayConstructor`, added in Java 9 as a hotfix to the incorrect constructor found on arrays via Lookup, to share the array access caching features. The result is that calling `MethodHandles.arrayConstructor` to create method handles is much faster.
Oracle JDK 20: Benchmark Mode Cnt Score Error Units MethodHandlesArrayConstructor.createWithAnewarray avgt 15 2.739 ± 0.058 ns/op MethodHandlesArrayConstructor.createWithMethodHandle avgt 15 3.313 ± 0.041 ns/op MethodHandlesArrayConstructor.methodHandleCreation avgt 15 61.874 ± 0.397 ns/op This patch: Benchmark Mode Cnt Score Error Units MethodHandlesArrayConstructor.createWithAnewarray avgt 15 3.067 ± 0.026 ns/op MethodHandlesArrayConstructor.createWithMethodHandle avgt 15 3.699 ± 0.042 ns/op MethodHandlesArrayConstructor.methodHandleCreation avgt 15 1.447 ± 0.004 ns/op ------------- Commit messages: - bug - 8307149: MethodHandles.arrayConstructor can be cached Changes: https://git.openjdk.org/jdk/pull/13819/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13819&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8307149 Stats: 126 lines in 4 files changed: 106 ins; 5 del; 15 mod Patch: https://git.openjdk.org/jdk/pull/13819.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/13819/head:pull/13819 PR: https://git.openjdk.org/jdk/pull/13819