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

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Nov 11 14:40:58 UTC 2014


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:

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,


More information about the core-libs-dev mailing list