On Fri, 2 May 2025 04:56:51 GMT, Shaojin Wen <s...@openjdk.org> wrote:

>> As another step toward the removal of the old generics infrastructure, I 
>> propose to remove the usages of generic parsing utilities and use the 
>> facilities provided by BytecodeDescriptor, already used by 
>> MethodType.fromDescriptorString. This also prevents extra validation cost in 
>> use sites to defend against generic types.
>> 
>> In this patch, BytecodeDescriptor and Wrapper see minor updates, mainly for 
>> better exception messages - previously, an unparseable char in the 
>> descriptor string just reports that char, and now the whole descriptor 
>> string is reported.
>> 
>> These behaviors are already covered by the tests added in JDK-8350704 #23788.
>> 
>> Testing: reflect/annotation/Class, running tier 1+2
>
> src/java.base/share/classes/java/lang/Class.java line 1565:
> 
>> 1563:             Class<?>[] parameterClasses = 
>> types.toArray(EMPTY_CLASS_ARRAY);
>> 1564: 
>> 1565:             final Class<?> enclosingCandidate = 
>> enclosingInfo.getEnclosingClass();
> 
> Suggestion:
> 
>             Constructor<?>[] candidates = enclosingInfo.getEnclosingClass()
>                                                        
> .privateGetDeclaredConstructors(false);
> 
> Here the local variable `enclosingInfo` is only used once, the above code may 
> be simpler

This patch intentionally did not change this part - and this part can get much 
more in-depth optimization; for example, arrayContentsEq can be shared for all 
`Class` arrays, copy of reflective objects can be simplified, etc.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24978#discussion_r2071104255

Reply via email to