JLS string concatenation clarification
Alex Buckley
alex.buckley at oracle.com
Mon Jan 27 11:29:07 PST 2014
Hi Vicente,
Generated code. Also, I realize that s+"" may generate different code
than ""+s - please indicate if that's the case.
Alex
On 1/27/2014 9:33 AM, Vicente-Arturo Romero-Zaldivar wrote:
> 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