RFR: 8305671: javac rejects semicolons in compilation units with no imports [v3]

Archie L. Cobbs duke at openjdk.org
Tue Apr 18 17:23:23 UTC 2023

On Tue, 18 Apr 2023 03:56:54 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>>> Doing what you suggest would probably be more straightforward
>> "More straightforward" is the right long term solution for the code.  The proposed patch is obscure and will confuse future developers working on this part of the code.
>>> but would risk breaking that.
>> You now have tests to ensure you don't break that.
>> The previous round of fix was inadequate, for not handling the case of no import statements. It is reasonable to (re)consider the logic for that part of the code.  And, it is reasonable to ensure the set of test cases covers all places where multiple semicolons are bad.
> Isn't the logic just
> * after a package declaration or import declaration, read and save excess semicolons
> * before an import statement, check there are no saved excess semicolons and report if there were any
> * (ignore any saved excess semicolons when you encounter the first type declaration (if any) or EOF)

OK I get what you're saying now (I think) and this is easy to fix. See if you like f2de70cfb08 better.


PR Review Comment: https://git.openjdk.org/jdk/pull/13361#discussion_r1170352440

More information about the compiler-dev mailing list