Error recovery in JavacParser could be improved

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: 8
    • Component/s: tools
    • b04
    • Verified

      Consider the following source code:
      ---
      public class Test {
           private void test(int i,) { }
      }
      ---

      Compiling this leads to three compile-time errors:
      ---
      $ javac Test.java
      Test.java:2: error: illegal start of type
           private void test(int i,) { }
                                   ^
      Test.java:2: error: ')' expected
           private void test(int i,) { }
                                    ^
      Test.java:2: error: ';' expected
           private void test(int i,) { }
                                      ^
      3 errors
      ---

      Out of these, only the first error is really significant, the other two errors are follow-up errors caused by tokens removed by code in JavacParser (in reportSyntaxError around line 459):
      ---
              if (token.pos == errorPos)
                  nextToken(); // guarantee progress
      ---

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: