Warnings Cleanup in java.util.<various> (more from hack day)

Martijn Verburg martijnverburg at gmail.com
Fri Dec 2 14:34:28 PST 2011


Is it worth adding a comment to that code, or should that sort of
performance implication be understood by OpenJDK contributors?

I only ask because I can see myself foolishly applying the StandardCharsets
'fix' in 6 months time when I've forgotten this thread :)

Cheers,
Martijn

On Friday, 2 December 2011, Xueming Shen <xueming.shen at oracle.com> wrote:
> Mike,
>
> I would prefer to leave the "utf8" usage here un-changed.
>
> From performance point of view, String.getBytes("UTF8") is faster
> than String.getBytes(StandardCharsets.UTF_8).
>
> I have some measurement when I did the related performance work at
>
> http://cr.openjdk.java.net/~sherman/7040220/client
> http://cr.openjdk.java.net/~sherman/7040220/server
>
> #String.getBytes() is the "encoding".
>
>
> -Sherman
>
> On 12/02/2011 12:02 PM, Michael Barker wrote:
>>>
>>> one change to Manifest.java introduces a bug !
>>>
>>> -                byte[] vb = value.getBytes("UTF8");
>>> -                value = new String(vb, 0, 0, vb.length);
>>> +                byte[] vb = value.getBytes(StandardCharsets.UTF_8);
>>> +                value = new String(vb, 0, 0, StandardCharsets.UTF_8);
>>>
>>>
>>> the last line should be:
>>> value = new String(vb, 0, 0, vb.length);
>>
>> Cheers, good spot.  I've attached an updated patch.
>>
>> Mike.
>
>


More information about the jdk8-dev mailing list