JLS question regarding Text Blocks

Jim Laskey james.laskey at oracle.com
Tue Apr 7 00:42:09 UTC 2020


The spec is correct as-is.  I have been made aware that white space in spec terms, as well as the compiler, is only space, tab and form-feed. Other white space (such as non-breaking space, em space, ...) is illegal and produces a javac error.

-- Jim


> On Apr 6, 2020, at 8:46 PM, Dan Smith <daniel.smith at oracle.com> wrote:
> 
>> On Apr 6, 2020, at 12:43 PM, Jim Laskey <james.laskey at oracle.com> 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.
>> 
>> Shouldn't the spec read as;
>> 
>> "The opening delimiter is a sequence that starts with three double quote characters ("""), continues with zero or more white space characters (Ex. space, tab, and form feed), and concludes with a line terminator."?
> 
> Is there a question about semantics here, or just a question of how best to present it?
> 
> Right now, TextBlockWhiteSpace defines precisely which characters can appear. Per 3.6, WhiteSpace is a grammar production that consists of 3 specific characters (space, horizontal tab, and form feed), plus the line terminators. TextBlockWhiteSpace excludes the line terminators.
> 
> Given this, I don't think redirecting through an abstract notion of "white space" or the "Character.isWhitespace" API would be helpful—the grammar has already nailed it down to exactly three characters.



More information about the amber-spec-observers mailing list