JLS question regarding Text Blocks
james.laskey at oracle.com
Tue Apr 7 00:54:32 UTC 2020
My interpretation was that concludes with a line terminator would make this a non-greedy consumption of white space.
But as I said in my response to Dan I didn’t understand white space in spec terms. I had been thinking in terms of the core lib interpretation.
> On Apr 6, 2020, at 4:05 PM, Alex Buckley <Alex.Buckley at oracle.com> wrote:
> On 4/6/2020 11:43 AM, Jim Laskey wrote:
>> In section 3.10.6 Text Blocks of the updated spec;
>> "The opening delimiter is a sequence that starts with three double quote characters ("""), continues with zero or more space, tab, and form feed characters, and concludes with a line terminator."
>> However, the JEP 378 description reads "The opening delimiter is a sequence of three double quote characters (""") followed by zero or more white spaces followed by a line terminator.
>> javac uses the Character.isWhitespace test for characters following the opening three double quote characters.
> Character::isWhiteSpace allows not only the JLS definition of whitespace -- space, tab, and FF -- but also LF and CR. So, javac would accept """ followed by some LF/CR characters (its idea of "zero or more white spaces") followed by a final LF/CR character (the "line terminator", at least according to the definition in JLS 3.4; can't find a definition in the API). That can't be right -- it extends the delimiter line into the content, so to speak.
More information about the amber-spec-experts