RFR (S) 8059677: Thread.getName() instantiates Strings

Chris Hegarty chris.hegarty at oracle.com
Tue Nov 11 16:10:35 UTC 2014


On 11 Nov 2014, at 14:40, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:

> Hi,
> 
> 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/

Looks good.

>  http://cr.openjdk.java.net/~shade/8059677/webrev.02.hs/

I skimmed this webrev, and it also looks fine to me.

-Chris.

> This version incorporates feedbacks from Chris, Staffan and David. I
> think it is very close to what we would like to push. Opinions?
> 
> Testing: JPRT, jdk/test/java/lang/Thread jtreg, hotspot/test/runtime/
> jtreg, vm.quick.testlist, nsk.jvmti.testlist, svc.quick.testlist,
> vm.tmtools.testlist
> 
> Thanks,
> -Aleksey.
> 
> 
> 
> 




More information about the core-libs-dev mailing list