RRF: 8187123: (reflect) Class#getCanonicalName and Class#getSimpleName is a part of performance issue

David Holmes david.holmes at oracle.com
Mon Apr 30 21:50:28 UTC 2018

Hi Claes,

On 30/04/2018 10:49 PM, Claes Redestad wrote:
> Hi,
> please review this patch to enable caching of getCanonicalName and 
> getSimpleName, repeated calls of which has been reported to be a 
> performance
> bottleneck. The caching improves performance of these methods by up to 20x.
> Rather than adding new fields to Class itself, which would have 
> footprint implications on classes, we can piggy-back on 
> Class$ReflectionData object.
> Webrev: http://cr.openjdk.java.net/~redestad/8187123/open.02/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8187123

Given String's are immune to unsafe publication races, you should be 
able to drop the volatile modifiers. That might save a few more cycles.


> Thanks!
> /Claes

More information about the core-libs-dev mailing list