JLS string concatenation clarification

Vicente-Arturo Romero-Zaldivar vicente.romero at oracle.com
Mon Jan 27 09:33:48 PST 2014


Hi Alex,

Are you interested in the generated code or in the compiler's internal 
representation?

Thanks,
Vicente

On 22/01/14 22:14, Alex Buckley wrote:
> To compiler-dev and others,
>
> Since the original question asked when the JLS allows compilers to 
> deviate from "always" creating a new String object, I would like to 
> know more about the following case:
>
> On 1/21/2014 4:45 PM, Alex Buckley wrote:
>> - "Semi" constant expressions like s+"". Concatenating the empty string
>> literal "" with a String expression is mentioned in
>> https://bugs.openjdk.java.net/browse/JDK-4036535. The expectation (per
>> JLS1) that a new String object is always created in this case is
>> misplaced (per the JDK's actual behavior). But, the JLS never clarified
>> this.
>
> If compiler authors can confirm (on-list or privately) that indeed 
> "concatenation with empty string does not create the new instance of 
> String", then I will clarify the JLS.
>
> Alex



More information about the compiler-dev mailing list