RFR: 8222852: Reduce String concat combinator tree shapes by folding constants into prependers

Claes Redestad claes.redestad at oracle.com
Fri Apr 26 13:55:06 UTC 2019

Hi Peter,

thanks for looking at this!

On 2019-04-26 11:08, Peter Levart wrote:
> Hi Claes,
> I wonder if it is even possible to create a test that would do something 
> like the following:
>          String s = ...
>          String s2 = s + "const1" + "const2" + s;
> ...since javac concatenates consecutive constants into a single 
> constant. So this actually becomes:
>          String s2 = s + "const1const2" + s;
> ...in bytecode.
> So what do you think? Is it important to test this or is it "obviously" 
> correct?

Adding an explicit sanity test for this seems reasonable to me, since 
it's a case allowable by the StringConcatFactory that is not expressible
via javac:


Also cleaned up a few unused imports etc.



More information about the core-libs-dev mailing list