Integrated: 8370865: Incorrect parser error for compact source files and multi-variable declarations

Jan Lahoda jlahoda at openjdk.org
Mon Nov 3 12:06:30 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.

This pull request has now been integrated.

Changeset: abf4f3da
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/abf4f3da76f413406de2860e4fbfacccfa15c221
Stats:     155 lines in 3 files changed: 153 ins; 0 del; 2 mod

8370865: Incorrect parser error for compact source files and multi-variable declarations

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list