Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8312204

unexpected else with statement causes compiler crash

    XMLWordPrintable

Details

    • b10
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Verified on Java version 22 (commit: 0e3d91dc213b5173f72e954d9b8e13e1b8343b23)


      A DESCRIPTION OF THE PROBLEM :
      an unexpected else keyword followed by a statement leads to compiler crash
      i.e. else STATEMENT; seems to crash the javac compiler

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      try to compile code with javac

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      produce a reasonable error message
      ACTUAL -
      Crashes with the following trace:
      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:3121)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:3090)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2818)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatements(JavacParser.java:2755)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2725)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2739)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.methodDeclaratorRest(JavacParser.java:4897)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.topLevelMethodOrFieldDeclaration(JavacParser.java:4771)
              at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseCompilationUnit(JavacParser.java:3988)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:652)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:629)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:689)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:1045)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler$InitialFileParser.parse(JavaCompiler.java:1979)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:1032)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:951)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)

      ---------- BEGIN SOURCE ----------
      public static void test(String[] args) {
              else 1;
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        1. Test.java
          0.1 kB
        2. Foo.java
          0.1 kB

        Issue Links

          Activity

            People

              jlahoda Jan Lahoda
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: