RFR: 8294961: Convert java.base/java.lang.reflect.ProxyGenerator to use the Classfile API to generate proxy classes [v10]
Chen Liang
liach at openjdk.org
Wed Mar 22 18:50:49 UTC 2023
On Wed, 22 Mar 2023 17:37:07 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> java.base java.lang.reflect.ProxyGenerator uses ASM to generate proxy classes and this patch converts it to use Classfile API.
>>
>> Please review.
>>
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 201 commits:
>
> - Merge branch 'master' into JDK-8294961
>
> # Conflicts:
> # src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java
> - ClassEntry caching ClassDesc to improve performance
> - MethodTypeDesc performance improvements
> - improved method descriptor construction
> - Apply suggestions from code review
>
> Co-authored-by: liach <7806504+liach at users.noreply.github.com>
> - Merge branch 'master' into JDK-8294961-proxy
> - Merge branch 'master' into JDK-8294961-proxy
> - Merge branch 'JDK-8294982' into JDK-8294961
> - removed obsolete javadoc from implementation classes
> - minor fix in CodeBuilder and added test cases to LDCTest
> - ... and 191 more: https://git.openjdk.org/jdk/compare/a2d8f634...2787185c
src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 77:
> 75: private static final MethodTypeDesc
> 76: MTD_boolean = MethodTypeDesc.of(CD_boolean),
> 77: MTD_void = MethodTypeDesc.of(CD_void),
Suggestion:
Already in `ConstantDescs`
src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 91:
> 89:
> 90: private static final String NAME_CTOR = "<init>";
> 91: private static final String NAME_CLINIT = "<clinit>";
Can be replaced with `ConstantDescs.INIT_NAME` and `CLASS_INIT_NAME`
src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 727:
> 725: private void codeWrapArgument(CodeBuilder cob, Class<?> type, int slot) {
> 726: if (type.isPrimitive()) {
> 727: cob.loadInstruction(TypeKind.fromDescriptor(type.descriptorString()).asLoadable(), slot);
Suggestion:
cob.loadInstruction(TypeKind.from(type).asLoadable(), slot);
src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java line 746:
> 744: cob.typeCheckInstruction(Opcode.CHECKCAST, prim.wrapperClass)
> 745: .invokevirtual(prim.wrapperClass, prim.unwrapMethodName, prim.unwrapMethodType)
> 746: .returnInstruction(TypeKind.fromDescriptor(type.descriptorString()).asLoadable());
Suggestion:
.returnInstruction(TypeKind.from(type).asLoadable());
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/10991#discussion_r1145201367
PR Review Comment: https://git.openjdk.org/jdk/pull/10991#discussion_r1145201895
PR Review Comment: https://git.openjdk.org/jdk/pull/10991#discussion_r1145206384
PR Review Comment: https://git.openjdk.org/jdk/pull/10991#discussion_r1145264294
More information about the core-libs-dev
mailing list