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

Error recovery in JavacParser could be improved

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8
    • 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
      ---

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

              Created:
              Updated:
              Resolved: