RFR: 8259050: Error recovery in lexer could be improved

Vicente Romero vromero at openjdk.java.net
Wed Jan 27 06:36:42 UTC 2021


On Tue, 26 Jan 2021 14:00:20 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> Consider code like:
> public class BrokenEscape {
>     private String s = "\uaaa";
> }
> (note the broken escape). This produces:
> $ javac BrokenEscape.java 
> BrokenEscape.java:2: error: illegal unicode escape
>     private String s = "\uaaa";
>                         ^
> BrokenEscape.java:2: error: unclosed string literal
>     private String s = "\uaaa";
>                        ^
> 2 errors
> 
> After this patch, it produces:
> $ javac BrokenEscape.java 
> BrokenEscape.java:2: error: illegal unicode escape
>     private String s = "\uaaa";
>                              ^
> 1 error
> which is the error message that used to be produced in the past.
> 
> The patch also improves the AST for source levels where text blocks are not supported, but are in fact present in the source code.

looks sensible

-------------

Marked as reviewed by vromero (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2239


More information about the compiler-dev mailing list