commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <>
Subject [jira] [Commented] (LANG-696) Deprecate ClassUtils getShortClassName in favor of Class getSimpleName
Date Fri, 29 Apr 2011 05:54:03 GMT


Henri Yandell commented on LANG-696:

So you're suggesting we have: 

  public static String getShortName(Object object, String valueIfNull) 
  public static String getShortName(Class<?> cls) 
  public static String getShortName(String className) 
  public static String getSimpleName(Class<?> cls) 
  public static String getSimpleName(Object object, String valueIfNull) 

With the difference between 'Short' and 'Simple' being Map.Entry vs Entry? We also use getShortName
in a few places and will have to decide which method we wish to use. 

Given that the maintenance for the method isn't huge; I'm beginning to think we should punt
on this for 3.0 and deal with at a later date. We can live with a deprecated getShortName
if need be.

> Deprecate ClassUtils getShortClassName in favor of Class getSimpleName
> ----------------------------------------------------------------------
>                 Key: LANG-696
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.6
>            Reporter: Gary D. Gregory
>            Assignee: Gary D. Gregory
>             Fix For: 3.0
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <>
> Hi All:
> Should we deprecate ClassUtils getShortClassName in favor of Class getSimpleName?
> The behavior of getShortClassName is undocumented for arrays in the Javadoc and is different
from getSimpleName.
> When I replace the guts of getShortClassName to call getSimpleName, one test fails:
> junit.framework.ComparisonFailure: null expected:<[ToStringStyleTest.]Person[name=John
Q. ...> but was:<[]Person[name=John Q. ...>
>     at junit.framework.Assert.assertEquals(
>     at junit.framework.Assert.assertEquals(
>     at org.apache.commons.lang3.builder.ShortPrefixToStringStyleTest.testPerson(
> For now, I've made a note in the Javdoc to consider using getSimpleName.

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message