RFR: 8312204: unexpected else with statement causes compiler crash

Jan Lahoda jlahoda at openjdk.org
Mon Jul 31 08:51:10 UTC 2023


Compiling (erroneous) code like:

void main() {
    else ;
}


Leads to:

$ javac --enable-preview -source 22 /tmp/Test.java 
An exception has occurred in the compiler (22-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.AssertionError
        at jdk.compiler/com.sun.tools.javac.parser.VirtualParser$VirtualScanner.errPos(VirtualParser.java:151)
        at jdk.compiler/com.sun.tools.javac.parser.JavacParser.doRecover(JavacParser.java:3122)
...


The proposed solution is to implement the two corresponding `errPos` methods for `VirtualScanner`.

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

Commit messages:
 - 8312204: unexpected else with statement causes compiler crash

Changes: https://git.openjdk.org/jdk/pull/15086/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15086&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8312204
  Stats: 41 lines in 2 files changed: 38 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/15086.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15086/head:pull/15086

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


More information about the compiler-dev mailing list