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

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
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.0


Added two null-safe ClassUtils.getSimpleName() APIs.

---------- Forwarded message ----------
From: Gary Gregory <[hidden email]>
Date: Mon, Apr 11, 2011 at 10:18 AM
Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
To: Commons Developers List <[hidden email]>


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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)

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

Gary D. Gregory commented on LANG-696:
--------------------------------------

---------- Forwarded message ----------
From: Henri Yandell <[hidden email]>
Date: Mon, Apr 11, 2011 at 4:26 PM
Subject: Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
To: Commons Developers List <[hidden email]>


+1 to rename getShortClassName to getSimpleName; sitting on top of the
JDK getSimpleName and providing null safety and whatever other
features are needed (for example array encoding).

Hen

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Gary D. Gregory commented on LANG-696:
--------------------------------------

---------- Forwarded message ----------
From: Gary Gregory <[hidden email]>
Date: Mon, Apr 11, 2011 at 6:43 PM
Subject: Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
To: Commons Developers List <[hidden email]>
Cc: Henri Yandell <[hidden email]>


On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <[hidden email]> wrote:

    +1 to rename getShortClassName to getSimpleName; sitting on top of the
    JDK getSimpleName and providing null safety and whatever other
    features are needed (for example array encoding).


You must mean deprecate getShortClassName (to remove in 4.0) and add getSimpleName. Right?

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Gary D. Gregory commented on LANG-696:
--------------------------------------

On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <[hidden email]> wrote:
> On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <[hidden email]> wrote:
>>
>> +1 to rename getShortClassName to getSimpleName; sitting on top of the
>> JDK getSimpleName and providing null safety and whatever other
>> features are needed (for example array encoding).
>
> You must mean deprecate getShortClassName (to remove in 4.0) and add
> getSimpleName. Right?

Nope. Remove getShortClassName and add getSimpleName. We're not
released yet so we can (and should) still make backwards compat
changes.

Hen

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Gary D. Gregory edited comment on LANG-696 at 4/21/11 3:29 PM:
---------------------------------------------------------------

---------- Forwarded message ----------
From: Gary Gregory <[hidden email]>
Date: Mon, Apr 11, 2011 at 6:43 PM
Subject: Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
To: Commons Developers List <[hidden email]>
Cc: Henri Yandell <[hidden email]>


On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <[hidden email]> wrote:
{noformat}
    +1 to rename getShortClassName to getSimpleName; sitting on top of the
    JDK getSimpleName and providing null safety and whatever other
    features are needed (for example array encoding).
{noformat}

You must mean deprecate getShortClassName (to remove in 4.0) and add getSimpleName. Right?

      was (Author: garydgregory):
    ---------- Forwarded message ----------
From: Gary Gregory <[hidden email]>
Date: Mon, Apr 11, 2011 at 6:43 PM
Subject: Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
To: Commons Developers List <[hidden email]>
Cc: Henri Yandell <[hidden email]>


On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <[hidden email]> wrote:

    +1 to rename getShortClassName to getSimpleName; sitting on top of the
    JDK getSimpleName and providing null safety and whatever other
    features are needed (for example array encoding).


You must mean deprecate getShortClassName (to remove in 4.0) and add getSimpleName. Right?
 

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Henri Yandell commented on LANG-696:
------------------------------------

The only issue I see is that inner classes report as only their class name in the new JVM code and not the surrounding class. So "Entry" instead of "Map.Entry". Our old code produced "Map.Entry". I see this in 5 test fails, one of which is your ToStringStyle fail.

We need to decide which is 'more' correct. Do we wrap the JVM method and fix this, or do we change our get(String) method to stop reporting the surrounding class.

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Gary D. Gregory commented on LANG-696:
--------------------------------------

I think 3.0 is the time to loose compatibility with 2.0 and gain interoperability with the JRE.

> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Matt Benson commented on LANG-696:
----------------------------------

+1; however I think either of "Map.Entry" or "Map$Entry" is actually more useful than "Entry".  I propose:

* eliminate redundancy by renaming {{getShortClassName()}} to {{getShortName()}}, returning simple name all the way up to top-level class
* add {{getSimpleName()}} for null-safe pass-through to {{Class.getSimpleName()}}
* document the difference between the two, with examples
* smile


> 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

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: 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.0
>
>
> Added two null-safe ClassUtils.getSimpleName() APIs.
> ---------- Forwarded message ----------
> From: Gary Gregory <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Henri Yandell commented on LANG-696:
------------------------------------

I've noted the different in the getShortName javadoc.

> 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 <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/LANG-696?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-696:
-------------------------------

    Fix Version/s:     (was: 3.0)
                   3.x

> 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 <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Henri Yandell edited comment on LANG-696 at 4/29/11 6:00 AM:
-------------------------------------------------------------

I've noted the difference in the getShortName javadoc.

      was (Author: bayard):
    I've noted the different in the getShortName javadoc.
 

> 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 <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Joerg Schaible commented on LANG-696:
-------------------------------------

There are actually more differences looking at classes defined within a method. The JDK version suppresses the synthetic numbering:

{noformat}
Index: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
===================================================================
--- src/test/java/org/apache/commons/lang3/ClassUtilsTest.java  (revision 1097888)
+++ src/test/java/org/apache/commons/lang3/ClassUtilsTest.java  (working copy)
@@ -97,6 +97,11 @@
         assertEquals("String[][]", ClassUtils.getShortClassName(String[][].class));
         assertEquals("String[][][]", ClassUtils.getShortClassName(String[][][].class));
         assertEquals("String[][][][]", ClassUtils.getShortClassName(String[][][][].class));
+        
+        // on-the-fly types
+        class Named extends Object {};
+        assertEquals("ClassUtilsTest.1", ClassUtils.getShortClassName(new Object(){}.getClass()));
+        assertEquals("ClassUtilsTest.1Named", ClassUtils.getShortClassName(Named.class));
     }
 
 
@@ -141,6 +146,11 @@
         assertEquals("String[][]", ClassUtils.getSimpleName(String[][].class));
         assertEquals("String[][][]", ClassUtils.getSimpleName(String[][][].class));
         assertEquals("String[][][][]", ClassUtils.getSimpleName(String[][][][].class));
+        
+        // on-the-fly types
+        class Named extends Object {};
+        assertEquals("", ClassUtils.getSimpleName(new Object(){}.getClass()));
+        assertEquals("Named", ClassUtils.getSimpleName(Named.class));
     }
 
     public void test_getSimpleName_Object() {
{noformat}

> 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 <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

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

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

    [ 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 <[hidden email]>
> Date: Mon, Apr 11, 2011 at 10:18 AM
> Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
> To: Commons Developers List <[hidden email]>
> 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