RFR: 8027682: javac wrongly accepts semicolons in package and import decls

Archie L. Cobbs duke at openjdk.org
Tue Feb 7 16:05:43 UTC 2023


On Tue, 7 Feb 2023 04:15:40 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>>> I would suggest to go ahead with a solution to report and ignore excess semicolons, since changing JLS is a bigger deal that cannot be done here. And even if we change JLS going forward, a solution to "report and ignore" excess semicolons might be worth back-porting.
>> 
>> Sounds like a good plan - thanks!
>
> @archiecobbs we use JavacParser::peekToken to look ahead, this method could be useful here

@vicente-romero-oracle wrote:
> I have created the CSR

Thanks for doing that. I've updated it, hopefully that's sufficient.

> we use JavacParser::peekToken to look ahead, this method could be useful here

Thanks, I wasn't aware of that method. I don't think it helps here though... the issue is I needed to consume arbitrarily many semi-colons at once, so that N consecutive semi-colons only generate one error, but also keep track of their source code positions in case they actually turn out to be valid _TopLevelClassOrInterfaceDeclaration_(s).

@amaembo wrote:
> So we may estimate that about 0.2% of projects may have compilation error after this change.

Thanks, that's really helpful to know.. I've included this info in the CSR.

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

PR: https://git.openjdk.org/jdk/pull/12448


More information about the compiler-dev mailing list