On Thu, 2 Nov 2023 11:53:09 GMT, Jim Laskey <jlas...@openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 
>> line 4057:
>> 
>>> 4055:         Name name = names.fromString(simplename);
>>> 4056:         JCModifiers implicitMods = F.at(Position.NOPOS)
>>> 4057:                 
>>> .Modifiers(Flags.FINAL|Flags.MANDATED|Flags.IMPLICIT_CLASS, List.nil());
>> 
>> I don't think the JVMS allows for a flag to have ACC_MANDATED flags?
>> 
>> 
>> It is a limitation of the class file format that only formal parameters and 
>> modules can be flagged as ACC_MANDATED 
>> ([§4.7.24](https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.7.24),
>>  
>> [§4.7.25](https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.7.25))
>>  to indicate that, despite being compiler-generated, they are not considered 
>> implementation artifacts. There is no way to flag other compiler-generated 
>> constructs so that they too are not considered implementation artifacts (JLS 
>> §13.1). This limitation means that reflective APIs of the Java SE Platform 
>> may not accurately indicate the "mandated" status of such constructs.
>
> The spec has been updated to include implicit classes.

Uhmm. In the spec I see implicit classes named here:


 For reference, the following constructs are declared implicitly in source 
code, but are not marked as mandated because only formal parameters and modules 
can be so marked in a class file (JVMS §4.7.24, JVMS §4.7.25):
 ```

Note the `but are not marked as mandated`.

I don't think javac sets the mandated flag for any of these. Note that 
ACC_MANDATED has the same value as the ACC_MODULE flag, so setting that flag on 
a class w/o at least filtering out when writing the classfile will be 
problematic.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16461#discussion_r1380009418

Reply via email to