RFR: 8215380: Backout accidental change to String::length

Roger Riggs Roger.Riggs at oracle.com
Fri Dec 14 14:06:34 UTC 2018


+1

On 12/13/2018 06:43 PM, Stuart Marks wrote:
> Hi Claes,
>
> Thank for catching this. Looks good.
>
> Note that the original changeset (JDK-8215281) went into JDK 12 before 
> the RDP1 fork, so this fix should also go into JDK 12. That's a 
> different repo now. It will then be auto-propagated to the JDK 
> mainline ("JDK 13").
>
> Since JDK-8215380 is a P3 bug, it's eligible to go into JDK 12 after 
> RDP1 without any further approval.
>
> s'marks
>
>
> On 12/13/18 3:20 PM, Claes Redestad wrote:
>> Hi,
>>
>> I need to revert an accidental change to String.length
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8215380
>> Patch inlined below
>>
>> Running the accidentally pushed version in naive microbenchmarks showed
>> that avoiding the shift operation can improve throughput of str.length()
>> by a small measure (~1.06x) for latin1-only inputs, neutral for mixed
>> or utf16-only inputs, but also adds a branch (visible in profiling)
>> which could blow up in more real cases. Regardless, it should be
>> reviewed and discussed on it's own merits. Sorry!
>>
>> /Claes
>>
>> diff -r 8bf9268df0e2 src/java.base/share/classes/java/lang/String.java
>> --- a/src/java.base/share/classes/java/lang/String.java    Thu Dec 13 
>> 15:31:05 2018 +0100
>> +++ b/src/java.base/share/classes/java/lang/String.java    Thu Dec 13 
>> 23:59:43 2018 +0100
>> @@ -664,7 +664,7 @@
>>        *          object.
>>        */
>>       public int length() {
>> -        return isLatin1() ? value.length : value.length >> UTF16;
>> +        return value.length >> coder();
>>       }
>>
>>       /**



More information about the core-libs-dev mailing list