RFR: 8320575: generic type information lost on mandated parameters of record's compact constructors [v13]

Chen Liang liach at openjdk.org
Wed Apr 24 21:22:29 UTC 2024


On Wed, 24 Apr 2024 19:53:41 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:
> 
>   Update test/jdk/java/lang/reflect/records/RecordReflectionTest.java
>   
>   Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>

Is it possible for us to check the length of `genericParamTypes`, so if `genericParamTypes.length == getParameterCount()`, then we assume the generic parameters are the real generic parameters. This approach would fix the record canonical constructors, and it would benefit other JVM languages that plan to declare generic types on mandated/synthetic parameters for Java's core reflection.

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

PR Comment: https://git.openjdk.org/jdk/pull/17070#issuecomment-2075865476


More information about the core-libs-dev mailing list