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

Claes Redestad redestad at openjdk.java.net
Fri May 27 19:40:36 UTC 2022


On Fri, 27 May 2022 19:27:44 GMT, ExE Boss <duke at openjdk.java.net> wrote:

> If `parameterList` is too slow for `List.of` copies the backing parameter types array, wouldn't calling `JavaUtilCollectionAccess::listFromTrustedArray` a better alternative, as it only allocates one wrapper and has better performance on `subList` than `Arrays.copyOfRange`?

Good observation that `MethodType::parameterList()` is a plausible candidate for `listFromTrustedArray`. That could be a good standalone and orthogonal RFE. 

I recall @rose00 musing about how he'd prefer it if `MethodType` and friends would have been implemented with `List.of`-style immutable lists rather than arrays. While I agree with him in principle we now have a mix of both worlds where we're converting between either representation haphazardly, making the implementation more complex in the process. It seems better for now to streamline the implementation with an early conversion to what we use internally (arrays) and stick with that.

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

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


More information about the core-libs-dev mailing list