If you look at the source code of Sun's implementation of Class.getSimpleName()
, you'll notice it seems to return a new instance of String each and every time you call it. Many other features in the Class class is however cached.
Since the simple name computation does not seem to be easy and there's nothing in the JavaDoc to say it has to return a new instance every time, it should be a good candidate for caching. I am wondering could there be any design reason why this is not cached?
I am asking because many frameworks use simple names all the time and this is such an easy thing to cache.