RFR: JDK-8306112 Implementation of JEP 445: Flexible Main Methods and Anonymous Main Classes (Preview) [v2]

Jim Laskey jlaskey at openjdk.org
Thu Apr 27 18:44:53 UTC 2023


On Thu, 27 Apr 2023 14:53:21 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   PreviewFeatures.isEnabled()
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java line 432:
> 
>> 430: 
>> 431:     // Restructure top level to be an top level anonymous class.
>> 432:     public static void constructAnonymousMainClass(JCCompilationUnit tree,
> 
> Question: any reason as to why this is done here and not in the parser? Typically we don't want to do tree transformation at parse time, as that messes up clients that want to access the "non-desugared" tree (such as IDE) and expect some mapping between source to AST. But if you do the rewriting in Enter, not much changes, that is, clients such as IDEs would still see something that doesn't resemble the source.

The source file name is not available until after parsing.

> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/VirtualParser.java line 191:
> 
>> 189:      * @param <E> return type of parserAction
>> 190:      */
>> 191:     public static <E> Optional<E> speculativeParse(JavacParser parser,
> 
> Since this is never use, and because of the TODO - should we just drop it for the time being?

dropping

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1179543180
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1179534229


More information about the core-libs-dev mailing list