RFR: 8370865: Incorrect parser error for compact source files and multi-variable declarations
Vicente Romero
vromero at openjdk.org
Fri Oct 31 14:31:57 UTC 2025
On Wed, 29 Oct 2025 13:51:09 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider code like:
>
> int f1, f2;
> void main() {}
>
>
> When javac's parser accepts `f1`, it sees `,`, but it won't parse this as top-level field declarations, failing with:
>
> /tmp/F.java:1: error: class, interface, annotation type, enum, record, method or field expected
> int f1, f2;
> ^
> 1 error
>
>
> This PR changes the parser to also accept the `,` as the next token when parsing top-level fields.
lgtm
-------------
Marked as reviewed by vromero (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28044#pullrequestreview-3404569563
More information about the compiler-dev
mailing list