Class.getSimpleName not suitable for non-Java classes

Aleksey Shipilev shade at redhat.com
Mon Mar 13 13:58:41 UTC 2017


On 03/11/2017 04:11 PM, Daniel Armak wrote:
> Here's a simpler proposal: what exactly doesn't work if you just change the
> three calls to Class.getSimpleName with getName?
> 
> As far as I can see, the only thing that's affected is that printed layout
> contains longer, less readable names. This is actually useful sometimes if you
> have classes with the same name in different packages. Regardless, a simple
> algorithm could be used here (e.g. discard everything until the last '.').
> 
> Also, Class.getName is already used to represent array component types
> (ClassData.java line 93). What's the difference?

Ah, I missed this part. Yes, JOL should indeed use FQDNs. I thought it did!

I don't think we care as much about larger printouts, and if we are, we can
shorten the package prefixes to be enough to disambiguate (e.g. j.u.HashMap
instead of java.util.HashMap).

Please submit the patch?

Thanks,
-Aleksey



More information about the jol-dev mailing list