commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <Joerg.Schai...@Elsag-Solutions.com>
Subject RE: [lang] ClassCastException in Enum.compareTo with anonymous inner classes
Date Fri, 14 Sep 2007 07:47:46 GMT
Samuel Fleischle wrote on Friday, September 14, 2007 9:19 AM:

> Hi Jörg,
> 
> thanks for your quick response and your approach to solve
> this issue. But anyway I think it should be possible to add
> these Enums to a Set without throwing a ClassCastException
> regardless of which class, anonymous inner class or whatever else the
> Enum is. 

Well, this is what is excplicitly documented in the JDK's docs for Comparable.compareTo().
The ValueEnum must ensure that it does not compare apples and oranges and two different classes
imply this.

The exception was surprising for you, since the old version of CL simply did this, but I'd
rather declare that impl of compareTo as buggy ;-)

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message