-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
minimal
-
-
Java API
-
JDK
Summary
Reflection is not retrieving generic type information for mandated parameters. Now that the parameters of compact constructors of record classes are mandated it makes sense to reconsider this decision.
Problem
When mapping the generic type information from the Signature classfile attribute to parameters, code reflection is currently ignoring both mandated and synthetic (constructor) parameters. This works well for local classes: for local classes, the parameter holding the enclosing class is mandated, but is not represented in the Signature field.
It does not work well for records whose components are of generic types, and have compact constructors. The parameters of the compact constructors are marked mandated, and even though they are represented in the Signature attribute, the mapping of the generic type information from Signature to the parameters will ignore them. This is problematic, as the generic parameters of the compact constructor may be useful for core reflection users.
Solution
For compact record constructors, the generic type information will be fetched from the Signature attribute for its parameters independently if they are mandated or not. This is a core-reflection only change, the compilation of records with compact constructor is not affected in any way.
Specification
No Change.
- csr of
-
JDK-8334608 generic type information lost on mandated parameters of record's compact constructors
-
- Resolved
-