RFR: 8294961: java.base java.lang.reflect.ProxyGenerator uses ASM to generate proxy classes [v3]
liach
duke at openjdk.org
Thu Mar 9 17:30:56 UTC 2023
On Thu, 9 Mar 2023 11:15:44 GMT, Adam Sotona <asotona at 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
More information about the core-libs-dev
mailing list