RFR: JDK-8315458 Implementation of Implicitly Declared Classes and Instance Main Method (Second Preview) [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Nov 2 11:15:04 UTC 2023


On Wed, 1 Nov 2023 19:14:22 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:

>> Address changes from JEP 445 to JEP 463.
>> 
>> - Move from a SYNTHETIC unnamed class to a MANDATED implicit class.
>> 
>> - Don't mark class on read.
>> 
>> - Remove reflection and annotation processing related to unnamed classes.
>> 
>> - Simplify main method search.
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove obsolete tests

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java line 249:

> 247:         STRING_TEMPLATES(JDK21, Fragments.FeatureStringTemplates, DiagKind.PLURAL),
> 248:         UNNAMED_CLASSES(JDK21, Fragments.FeatureUnnamedClasses, DiagKind.PLURAL),
> 249:         IMPLICIT_CLASSES(JDK21, Fragments.FeatureImplicitClasses, DiagKind.PLURAL),

Should this be JDK22?

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java line 442:

> 440:                           Errors.ClassPublicShouldBeInFile(topElement, tree.name));
> 441:             }
> 442:             if ((tree.mods.flags & IMPLICIT_CLASS) != 0) {

I'm not 100% sure about this. Another option would be to tweak Resolve::findType and make sure that `typeNotFound` (or some more specific message!) is returned when an implicit class is referred to by name. If you look at the first few lines in that method you will see:


if (name == names.empty)
            return typeNotFound; // do not allow inadvertent "lookup" of anonymous types


So, there's already some logic there for skipping some types.

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

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


More information about the compiler-dev mailing list