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

Error recovery in lexer could be improved

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 16
    • tools
    • None
    • b08

    Description

      There are two scenarios in lexer where the error recovery could be improved:
      ---
      public class BrokenUnicodeEscape {
           private String s = "\uaaa";
      }
      ---

      Will produce:
      ---
      /tmp/BrokenUnicodeEscape.java:2: error: illegal unicode escape
           private String s = "\uaaa";
                               ^
      /tmp/BrokenUnicodeEscape.java:2: error: unclosed string literal
           private String s = "\uaaa";
                              ^
      2 errors
      ---

      But used to produce:
      ---
      /tmp/BrokenUnicodeEscape.java:2: error: illegal unicode escape
           private String s = "\uaaa";
                                    ^
      1 error
      ---

      Second case:
      ---
      public class UnsupportedTextBlock {
           private String s = """
                              """;
      }
      ---

      When compiled with -source 14, the text block is replaced with (ERROR) in the AST, but before it used to contain the text block content (after reporting a proper error).

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: