On Thu, 9 Mar 2023 11:15:44 GMT, Adam Sotona <asot...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 661: >> >>> 659: */ >>> 660: private void generateMethod(ClassBuilder clb, ClassDesc >>> className) { >>> 661: MethodTypeDesc desc = MethodType.methodType(returnType, >>> parameterTypes).describeConstable().orElseThrow(); >> >> Can we convert this line to: >> >> MethodTypeDesc desc = MethodTypeDesc.of(toClassDesc(returnType), >> Arrays.stream(parameterTypes).map(ProxyGenerator::toClassDesc).toArray(ClassDesc[]::new)); >> >> >> Mainly due to that `MethodType` creation involves a lot of unrelated process >> such as generating lambda forms, and we can remove the `MethodType` import >> as a result. > > Isn't the "unrelated process such as generating lambda forms" critical for > the `ProxyGenerator` functionality? More accurately, I mean the overhead generated by this: https://github.com/openjdk/jdk/blob/1e9942aa112edca33f964db127df6c9ce41e86ff/src/java.base/share/classes/java/lang/invoke/MethodType.java#L408 That method type construction is somewhat expensive and involves extra work besides simply storing the return class and the parameter classes. ------------- PR: https://git.openjdk.org/jdk/pull/10991