RFR: 8245153 Unicode encoded double-quoted empty string does not compile

Adam Sotona adam.sotona at oracle.com
Thu May 28 08:38:16 UTC 2020

please help me to review fix of Unicode encoded double-quoted empty string compilation.
I found the root cause is in com.sun.tools.javac.parser.JavaTokenizer::scanString(int pos). It is trying to un-read unicode quotes by calling com.sun.tools.javac.parser.UnicodeReader::reset(int pos), however that approach works only luckily when one source character matches to one String character (standard quotes in this case).
If the quotes are written in Unicode notation \u0022\u0022 , the reset call moves reader.bp cursor to original pos-1 position and reads one character.  
As the initial pos parameter points AFTER the last parsed character, so position of the first backslash from \u0022\u0022 is already lost and next character parsed is number 2 instead of unicode quotes.
The fix just repositions reader to the right place, no matter if quotes are standard nor unicode encoded. 
Plus there is a new test added for this case.

JBS: https://bugs.openjdk.java.net/browse/JDK-8245153
webrev: http://cr.openjdk.java.net/~asotona/8245153/

All Tier 1, 2 and 3 tests are passing.

Thanks for the review,

More information about the compiler-dev mailing list