RFR (S) 8059677: Thread.getName() instantiates Strings
Aleksey Shipilev
aleksey.shipilev at oracle.com
Wed Nov 12 23:01:39 UTC 2014
On 11.11.2014 17:40, Aleksey Shipilev wrote:
> On 11/09/2014 09:45 PM, Aleksey Shipilev wrote:
>> Thread.getName() returns String, and does new String instantiation every
>> time, because the thread name is stored in char[]. Even though we use a
>> private String constructor that shares the char[] array without copying
>> it, this still hurts some use cases (think extra-fast logging). To the
>> extent some people actually maintain Map<Thread, String> to avoid it.
>> https://bugs.openjdk.java.net/browse/JDK-8059677
>>
>> Here's the attempt to maintain String instead of char[]:
>> http://cr.openjdk.java.net/~shade/8059677/webrev.01.jdk/
>> http://cr.openjdk.java.net/~shade/8059677/webrev.01.hs/
>
> Updated webrevs:
> http://cr.openjdk.java.net/~shade/8059677/webrev.02.jdk/
> http://cr.openjdk.java.net/~shade/8059677/webrev.02.hs/
All right, third time a charm. All reviewers seem to be happy with these
changes:
http://cr.openjdk.java.net/~shade/8059677/webrev.03.jdk/
http://cr.openjdk.java.net/~shade/8059677/webrev.03.hs/
Coleen had volunteered to sponsor them (thanks!), here are the changesets:
http://cr.openjdk.java.net/~shade/8059677/8059677-jdk.changeset
http://cr.openjdk.java.net/~shade/8059677/8059677-hs.changeset
Thanks,
-Aleksey.
More information about the core-libs-dev
mailing list