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

Jonathan Gibbons jjg at openjdk.org
Mon Apr 17 23:33:43 UTC 2023


On Wed, 5 Apr 2023 18:37:05 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:

> The fix for [JDK-8027682](https://bugs.openjdk.org/browse/JDK-8027682) created a new bug in which a program like this:
> 
> package p;;
> 
> would be rejected.
> 
> This is due to the previous fix swallowing all the semicolons. Instead, in the case of semicolons followed by EOF, it needs to swallow all but the last one.

test/langtools/tools/javac/parser/ExtraPackageSemicolon.java line 65:

> 63:         runTest("Test2.java", "package p;;");
> 64:         runTest("Test3.java", "package p;; ;; ;; ;;; ;;; ;;; ;;");
> 65:     }

I suggest including test cases where the package statement and semicolons are followed by something else, like an import declaration or a type declaration.

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

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


More information about the compiler-dev mailing list