RFR: 8320575: generic type information lost on mandated parameters of record's compact constructors [v17]
Chen Liang
liach at openjdk.org
Sat Apr 27 00:17:06 UTC 2024
On Fri, 26 Apr 2024 23:54:17 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> Reflection is not retrieving generic type information for mandated parameters. This is a known issue which has been explicitly stated in the API of some reflection methods. Fix for [JDK-8292275](https://bugs.openjdk.org/browse/JDK-8292275) made the parameters of compact constructors of record classes `mandated` as specified in the spec. But this implied that users that previous to this change could retrieve the generic type of parameters of compact constructors now they can't anymore. The proposed fix is to try to retrieve generic type information for mandated parameters if available plus changing the spec of the related reflection methods.
>>
>> TIA
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>
> code refactoring
src/java.base/share/classes/java/lang/reflect/Executable.java line 348:
> 346: final Type[] out = new Type[nonGenericParamTypes.length];
> 347: final Parameter[] params = getParameters();
> 348: if (getDeclaringClass().isRecord() && this instanceof Constructor) {
Sorry for late notice but we can move the 2 variable allocation to the else block, to speed up the record constructor path.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17070#discussion_r1581636171
More information about the core-libs-dev
mailing list