On Mon, 5 Jun 2023 17:27:19 GMT, Mandy Chung <mch...@openjdk.org> wrote:
>> Chen Liang has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains two commits: >> >> - Forgot to upload latest micro >> - general optimizations to MTD, no longer change backing storage > > src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java line > 84: > >> 82: paramTypes = new ClassDesc[paramCount]; >> 83: for (int i = 0; i < paramCount; i++) { >> 84: paramTypes[i] = >> validateParameter(ClassDesc.ofDescriptor(types.get(i + 1))); > > It seems useful to have a static factory method to take a trusted copy of > parameter types and it will validate the parameters before constructing > `MethodTypeDescImpl` instance. Parameter validation in one single place. > Several methods doing the validation can simply call this factory method and > the code would be cleaner. > > `insertParameterTypes` can call it as well and overhead of re-validating > existing parameter types isn't a big issue. Should I just keep track of the slot count of MethodTypeDesc instead? Having a slot count implicitly requires validating the parameters, and the slot count can be used to eagerly reject `resolveConstantDesc` on MTD with over 255 slots. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13186#discussion_r1218664978