You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2011/04/11 16:18:36 UTC
[Lang] ClassUtils getShortClassName != Class getSimpleName
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.
--
Thank you,
Gary
http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Henri Yandell <fl...@gmail.com>.
On Thu, Apr 21, 2011 at 12:01 PM, Gary Gregory <ga...@gmail.com> wrote:
> On Thu, Apr 21, 2011 at 2:38 PM, Henri Yandell <fl...@gmail.com> wrote:
>>
>> On Thu, Apr 21, 2011 at 8:31 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>> > On Mon, Apr 11, 2011 at 7:19 PM, Henri Yandell <fl...@gmail.com>
>> > wrote:
>> >>
>> >> On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <ga...@gmail.com>
>> >> wrote:
>> >> > On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com>
>> >> > 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
>> >
>> > getShortClassName is in 2.6.
>>
>> So? It can be removed in 3.0 if it's pointless and replaced by
>> getSimpleName.
>
> Yes, that's true. I thought it would be polite to deprecate the method first
> but I suppose there is no rule that says we have to do it that way.
>
> I was just surprised by methods disappearing in WSS4J 1.6 from 1.5.x without
> deprecation in 1.5.x.
>
> Because major releases can break things, I now understand it is permitted to
> do this kind of change.
>
> We now two new methods:
>
> org.apache.commons.lang3.ClassUtils.getSimpleName(Class<?>)
> org.apache.commons.lang3.ClassUtils.getSimpleName(Object, String)
>
> Which should replace:
>
> getShortClassName(Class<?>)
> getShortClassName(Object, String)
>
> The question is, what do we do about:
>
> org.apache.commons.lang3.ClassUtils.getShortClassName(String)
>
> Changing the impl to call getSimpleName(Class<?>) with the result of
> Class.forName() smells wrong.
Keep it and simply rename to getSimpleName with the intent that it
would match the JVM version?
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Apr 21, 2011 at 2:38 PM, Henri Yandell <fl...@gmail.com> wrote:
> On Thu, Apr 21, 2011 at 8:31 AM, Gary Gregory <ga...@gmail.com>
> wrote:
> > On Mon, Apr 11, 2011 at 7:19 PM, Henri Yandell <fl...@gmail.com>
> wrote:
> >>
> >> On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <ga...@gmail.com>
> >> wrote:
> >> > On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com>
> >> > 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
> >
> > getShortClassName is in 2.6.
>
> So? It can be removed in 3.0 if it's pointless and replaced by
> getSimpleName.
>
Yes, that's true. I thought it would be polite to deprecate the method first
but I suppose there is no rule that says we have to do it that way.
I was just surprised by methods disappearing in WSS4J 1.6 from 1.5.x without
deprecation in 1.5.x.
Because major releases can break things, I now understand it is permitted to
do this kind of change.
We now two new methods:
org.apache.commons.lang3.ClassUtils.getSimpleName(Class<?>)
org.apache.commons.lang3.ClassUtils.getSimpleName(Object, String)
Which should replace:
getShortClassName(Class<?>)
getShortClassName(Object, String)
The question is, what do we do about:
org.apache.commons.lang3.ClassUtils.getShortClassName(String)
Changing the impl to call getSimpleName(Class<?>) with the result of
Class.forName() smells wrong.
Gary
Gary
>
> Hen
>
--
Thank you,
Gary
http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Henri Yandell <fl...@gmail.com>.
On Thu, Apr 21, 2011 at 8:31 AM, Gary Gregory <ga...@gmail.com> wrote:
> On Mon, Apr 11, 2011 at 7:19 PM, Henri Yandell <fl...@gmail.com> wrote:
>>
>> On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <ga...@gmail.com>
>> wrote:
>> > On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com>
>> > 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
>
> getShortClassName is in 2.6.
So? It can be removed in 3.0 if it's pointless and replaced by getSimpleName.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Gary Gregory <ga...@gmail.com>.
On Mon, Apr 11, 2011 at 7:19 PM, Henri Yandell <fl...@gmail.com> wrote:
> On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <ga...@gmail.com>
> wrote:
> > On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com>
> 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
>
getShortClassName is in 2.6.
Gary
--
Thank you,
Gary
http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Henri Yandell <fl...@gmail.com>.
On Mon, Apr 11, 2011 at 3:43 PM, Gary Gregory <ga...@gmail.com> wrote:
> On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Gary Gregory <ga...@gmail.com>.
On Mon, Apr 11, 2011 at 4:26 PM, Henri Yandell <fl...@gmail.com> 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?
Gary
> Hen
>
> On Mon, Apr 11, 2011 at 7:18 AM, Gary Gregory <ga...@gmail.com>
> wrote:
> > 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.
> >
> > --
> > Thank you,
> > Gary
> >
> > http://garygregory.wordpress.com/
> > http://garygregory.com/
> > http://people.apache.org/~ggregory/
> > http://twitter.com/GaryGregory
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
Thank you,
Gary
http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory
Re: [Lang] ClassUtils getShortClassName != Class getSimpleName
Posted by Henri Yandell <fl...@gmail.com>.
+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
On Mon, Apr 11, 2011 at 7:18 AM, Gary Gregory <ga...@gmail.com> wrote:
> 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.
>
> --
> Thank you,
> Gary
>
> http://garygregory.wordpress.com/
> http://garygregory.com/
> http://people.apache.org/~ggregory/
> http://twitter.com/GaryGregory
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org