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

Error recovery in JavacParser could be improved

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b04
    • Verification:
      Verified

      Description

      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
      ---

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: