The current implementation of ofDescriptor puts return type and parameter types together in an ArrayList, and then splits them into return type and array of parameter types. This ArrayList creation is unnecessary, considering most descriptors only have few parameter types.
By splitting return type and parameter types separately and scanning the descriptor first to get the number of parameters, we can just allocate an exact, trusted array for the resulting MethodTypeDesc without copy. ------------- Commit messages: - more descString - Consolidated parsing, now supports 9 params - clean up Wrapper.forPrimitiveType - use ConstantDescs.MTD_void - optimization for `Ljava/lang/Object;` - more descString - private PrimitiveClassDescImpl constructor - private PrimitiveClassDescImpl constructor - minor refactor - add comments - ... and 32 more: https://git.openjdk.org/jdk/compare/74066bcc...ee321904 Changes: https://git.openjdk.org/jdk/pull/20611/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20611&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8338532 Stats: 272 lines in 11 files changed: 160 ins; 61 del; 51 mod Patch: https://git.openjdk.org/jdk/pull/20611.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/20611/head:pull/20611 PR: https://git.openjdk.org/jdk/pull/20611