Description
The getShortCanonicalName should return the canonical name minus the package name from a Class.
Also, the javadoc of an overloaded getShortCanonicalName states,
If the class is an inner class then the result value will not contain the outer classes. This way the behavior of this method is different from getShortClassName(String). The argument in that case is class name and not canonical name and the return value retains the outer classes.
But for inner class, its behaviour is similar to getShortClassName.
Class<?> clazz = Map.Entry.class; System.out.println(ClassUtils.getShortCanonicalName(clazz));
Actual: Map.Entry
Expected: Entry
Looking into the implementation, it calls getShortCanonicalName(cls.getName()). I believe it should have been getShortCanonicalName(cls.getCanonicalName())
public static String getShortCanonicalName(final Class<?> cls) { if (cls == null) { return StringUtils.EMPTY; } return getShortCanonicalName(cls.getName()); //<--- } public static String getShortCanonicalName(final String canonicalName) { return getShortClassName(getCanonicalName(canonicalName)); }