You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "david cogen (JIRA)" <ji...@apache.org> on 2012/05/17 19:10:07 UTC

[jira] [Commented] (LANG-696) Deprecate ClassUtils getShortClassName in favor of Class getSimpleName

    [ https://issues.apache.org/jira/browse/LANG-696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13277982#comment-13277982 ] 

david cogen commented on LANG-696:
----------------------------------

I do not believe it should be deprecated, and the suggestion to consider using Class.getSimpleName() is misleading, because there are more differences than the one mentioned. For example, getShortClassName() formats an anonymous class like "klass.1" but Class.getSimpleName() formats it as "".

I rely on getShortClassName()'s behavior and use it frequently.
                
> Deprecate ClassUtils getShortClassName in favor of Class getSimpleName
> ----------------------------------------------------------------------
>
>                 Key: LANG-696
>                 URL: https://issues.apache.org/jira/browse/LANG-696
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 2.6
>            Reporter: Gary D. Gregory
>            Assignee: Gary D. Gregory
>             Fix For: 3.x
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <ga...@gmail.com>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <de...@commons.apache.org>
> 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(Assert.java:81)
>     at junit.framework.Assert.assertEquals(Assert.java:87)
>     at org.apache.commons.lang3.builder.ShortPrefixToStringStyleTest.testPerson(ShortPrefixToStringStyleTest.java:86)
> For now, I've made a note in the Javdoc to consider using getSimpleName.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira