Bug: Compact record constructor is missing generic type info on parameters

Remi Forax forax at univ-mlv.fr
Wed Apr 24 11:49:09 UTC 2024


> From: "Patrick Doyle" <p.r.doyle at gmail.com>
> To: "Liam Miller-Cushon" <cushon at google.com>
> Cc: "Archie Cobbs" <archie.cobbs at gmail.com>, "amber-dev" <amber-dev at openjdk.org>
> Sent: Wednesday, April 24, 2024 12:53:52 PM
> Subject: Re: Bug: Compact record constructor is missing generic type info on
> parameters

> Thanks, Liam. Perhaps Java 22 doesn't use the "mandated" flag anymore? Oracle
> has closed by bug as "not a bug": [
> https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8331026 |
> https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8331026 ]

> > The observations on Windows 11:
> > JDK 22: Passed all tests.
> > Close as not an issue.

> Given that Gradle doesn't support Java 22 yet, this is a bit tricky for me to
> try at the moment. I know when I build it with Java 21 and then run it with 22,
> it still fails, but based on the observations from Oracle, I assume it would
> pass if I compiled the class with Java 22.

gradle 8.7 supports Java 22 
https://docs.gradle.org/current/release-notes.html#support-for-building-projects-with-java-22 

> Question: would it make sense to back-port the fix from Java 22 to the LTS
> versions (17 and 21)? If so, who do I contact about that?

> Thanks again,
> --
> Patrick Doyle
> [ mailto:p.r.doyle at gmail.com | p.r.doyle at gmail.com ]

regards, 
Rémi 

> On Tue, Apr 23, 2024 at 3:51 PM Liam Miller-Cushon < [ mailto:cushon at google.com
> | cushon at google.com ] > wrote:

>> The only noteworthy difference in the class file for the record with the compact
>> constructor is that the parameter has the 'mandated' flag set.

>> I think the behaviour is due to [
>> https://github.com/openjdk/jdk/blob/09b88098ff544fec1a4e94bfbbdc21b6c8433abb/src/java.base/share/classes/java/lang/reflect/Executable.java#L344-L345
>> | this logic ] in Executable#getAllGenericParameterTypes (which is used by
>> Parameter#getParameterizedType):

>> // If we hit a synthetic or mandated parameter,
>> // use the non generic parameter info.

>> On Tue, Apr 23, 2024 at 12:47 PM Patrick Doyle < [ mailto:p.r.doyle at gmail.com |
>> p.r.doyle at gmail.com ] > wrote:

>>> Thanks, Archie. I've submitted the bug report to [ http://bugs.java.com/ |
>>> bugs.java.com ] .
>>> --
>>> Patrick Doyle
>>> [ mailto:p.r.doyle at gmail.com | p.r.doyle at gmail.com ]

>>> On Tue, Apr 23, 2024 at 3:29 PM Archie Cobbs < [ mailto:archie.cobbs at gmail.com |
>>> archie.cobbs at gmail.com ] > wrote:

>>>> Hi Patrick,

>>>> If it's just a normal bug, file it at [ https://bugs.java.com/bugdatabase/ |
>>>> https://bugs.java.com/bugdatabase/ ] and it will eventually get triaged over to
>>>> [ https://bugs.openjdk.org/ | https://bugs.openjdk.org/ ]

>>>> If it's a language question, e.g., a suggestion for some minor improvement, this
>>>> list would be appropriate.

>>>> -Archie

>>>> On Tue, Apr 23, 2024 at 1:38 PM Patrick Doyle < [ mailto:p.r.doyle at gmail.com |
>>>> p.r.doyle at gmail.com ] > wrote:

>>>>> Hi all,

>>>>> Is this the wrong place to report bugs like this? What would be the right place?

>>>>> Thanks,
>>>>> --
>>>>> Patrick Doyle
>>>>> [ mailto:p.r.doyle at gmail.com | p.r.doyle at gmail.com ]

>>>>> On Mon, Feb 19, 2024 at 8:52 AM Patrick Doyle < [ mailto:p.r.doyle at gmail.com |
>>>>> p.r.doyle at gmail.com ] > wrote:

>>>>>> Hi all,

>>>>>> I have a JUnit5 test case that demonstrates that if you use the compact
>>>>>> constructor syntax in a record, the reflection info will be missing generic
>>>>>> type information. Implicit constructors work fine, as do explicit canonical
>>>>>> constructors.

>>>>>> I found this on Temurin 21.0.2 and the Adoptium project suggested I post here.

>>>>>> The unit test can be found in the Adoptium bug report: [
>>>>>> https://github.com/adoptium/adoptium-support/issues/1025 |
>>>>>> https://github.com/adoptium/adoptium-support/issues/1025 ]

>>>>>> Let me know if there's anything I can do to help.

>>>>>> Thanks,
>>>>>> --
>>>>>> Patrick Doyle
>>>>>> [ mailto:p.r.doyle at gmail.com | p.r.doyle at gmail.com ]

>>>> --
>>>> Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240424/5d0b1290/attachment-0001.htm>


More information about the amber-dev mailing list