commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <>
Subject [jira] Commented: (LANG-331) Fix for LANG-259 broke ValuedEnum.compareTo() on subclassed enumerations
Date Thu, 09 Aug 2007 07:21:43 GMT


Henri Yandell commented on LANG-331:

I wonder if the solution is simply to state the 'if different classloader' better.

ie) Rather than doing:

        if (other.getClass() != this.getClass()) {

Instead do:

        if (other.getClass().getClassLoader() != this.getClass().getClassLoader()) {

That wouldn't help if your two separate grandchildren enums are in different classloaders
and you still want them viewed equal, but I'm not sure what would (without turning into lots
of code).

That allows RandomEnum.RED to equal MyEnum.RED, so you also need to check for inheritence:

Attaching patch.

> Fix for LANG-259 broke ValuedEnum.compareTo() on subclassed enumerations
> ------------------------------------------------------------------------
>                 Key: LANG-331
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Michael Sclafani
>             Fix For: 2.3.1
>         Attachments: LANG-331.patch
> I have a ValuedEnum abstract subclass that I further subclass to attach useful implementation
behaviors. The base class overrides getEnumClass(). The fix for LANG-259 broke compareTo()
since it compares getClass(), not getEnumClass().

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message