Bug in multi-line string declaration

Robert Field robert.field at oracle.com
Thu Feb 19 01:20:52 UTC 2015


The problem turns out to be position information loss in parser string 
folding.

The parser concatenates the strings but does not fix the position 
information.  I don't know if this can be seen as a compiler bug for 
javac because I don't know if this position information could ever show 
in an error message -- I couldn't think of a way -- all error messages 
wanted to point to the plus (as opposed to the beginning of the expression).

Anyway, fixable by passing in -XDallowStringFolding=false

Thanks,
Robert


On 02/18/15 14:42, Maurizio Cimadamore wrote:
>
> On 18/02/15 21:03, Jonathan Gibbons wrote:
>> There's two parts to this.    There's whatever is going on in kulla, 
>> but the reference to the unary operator '+++' is a javac quirk that 
>> (coincidentally) was should have been fixed by Maurizio's work on his 
>> refactoring of the operator code in javac.
> Yeah - that's fixed as part of the latest operator work; unary '+' was 
> turned into '+++' back in the early JDK 8 days because javac was 
> resolving operators using overload resolution and there were like 12 
> different versions of '+' most of which didn't apply if you were 
> really after an unary operator. Since in vanilla javac this kind of 
> error is never possible (i.e. the parser will reject such code), using 
> '+++' was an hacky way to squeeze more performances out of javac 
> (avoiding all the useless overloads).
>
> Now that a more general solution is in place, the hack is no longer 
> needed - but as Jon says, the problem here as probably very little to 
> do with '+' vs. '+++' and more with parser possibly not constructing 
> the right AST.
>
> Maurizio
>>
>> -- Jon
>>
>> On 02/18/2015 08:46 AM, andrei.eremeev wrote:
>>> Hi REPL team,
>>>
>>> Multi-line string declaration fails with error : bad operand type 
>>> java.lang.String for unary operator '+++'.
>>>
>>> -> String s = "aaa" +
>>> >> "aaa";
>>> |  Error:
>>> |  bad operand type java.lang.String for unary operator '+++'
>>> |  String s = "aaa" +
>>> |  "aaa";
>>> |                   ^
>>>
>>> Andrei Eremeev
>>
>



More information about the kulla-dev mailing list