Class.getSimpleName not suitable for non-Java classes

Daniel Armak danarmak at
Thu Mar 16 13:16:53 UTC 2017

Thanks! This resolves the issue of confusing a class named "int" with the
primitive type.

Unfortunately, it doesn't resolve the issue of getSimpleName throwing due
to JDK-8057919, because getCanonicalName calls getSimpleName.

Actually, I think getCanonicalName isn't a good idea regardless, because it
returns null for anonymous classes, and I think you should use getName
instead in those cases. So you might as well use getName also if
getCanonicalName throws, or just always use it.

Daniel Armak

On Thu, Mar 16, 2017 at 2:38 PM, Aleksey Shipilev <shade at> wrote:

> On 03/13/2017 07:57 PM, Daniel Armak wrote:
> > The attached patch simply replaces the 3 calls to getSimpleName with
> getName.
> > The tests pass successfully. The output of sample #1 now looks like this:
> I pushed the variant of this, along with tests and output tuneups as:
> Please test, and make corrections if you see problems in your use cases.
> If no
> problems are found, I would promote to Maven Central.
> Thanks,
> -Aleksey

More information about the jol-dev mailing list