Mandated/implicit parameters

Alex Buckley alex.buckley at oracle.com
Wed Jun 8 17:43:59 UTC 2022


On 6/6/2022 6:54 PM, Joseph D. Darcy wrote:> On 5/24/2022 8:52 AM, Alex 
Buckley wrote:
>> On 5/23/2022 11:27 PM, Hannes Greule wrote:
>>> Looking into it a bit deeper, it also seems like the parameters
>>> of a compact constructor for records are never marked as
>>> mandated, even when compiling with the -parameters flag (but the
>>> MethodParameters attribute is always written or record
>>> constructors).
>>
>> That is weird, and sounds like a javac bug.
> 
> JDK-8234908: consider if the MANDATED flag should be applied to record 
> members added by the compiler
> https://bugs.openjdk.org/browse/JDK-8234908

The bug in javac is that when MethodParameters is emitted for a record 
ctor (which is apparently "always"), the ACC_MANDATED flag is not set 
for the ctor's parameters even in cases when it should be set. When 
should it be set? When the ctor is implicitly declared according to JLS 
8.10.4.

JDK-8234908 is talking about something different: being able to mark the 
ctor itself (and other methods) as mandated, not just parameters. That's 
a fine goal, but it's not responsive to the observation by Hannes Greule 
about missing mandated parameters.

(I linked to this thread in the Description of JDK-8234908, without 
changing its original text: "the MANDATED flag has been used so far for 
parameters added by the compiler. Now the compiler is adding more 
members that are not parameters only, like accessors and constructors in 
records. We should consider if the flag should be applied to those too. 
This flag would only be visible by source reflection")

Alex


More information about the compiler-dev mailing list