commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergei Ivanov (JIRA)" <>
Subject [jira] Commented: (COLLECTIONS-110) [collections] Support parametized classes with commons.collections.
Date Tue, 30 May 2006 21:24:30 GMT
    [ ]

Sergei Ivanov commented on COLLECTIONS-110:

[cross-posted from Bugzilla]

------- Additional Comment #6 From Sergei S. Ivanov 2006-05-22 21:49 [reply] ------- 
(In reply to comment #4)
> The project was done without good technical knowledge of Java 1.5 
> classes.
> class Set<E> {
>     void add(E d) {...} // that's wrong!!!
> }
> - the method add should read
>     void add(<? extends E> d) {...} // so any subclass of E is acceptable.

I am sorry to disappoint you, but the code above is not wrong. add(E) will 
accept any subclass of actual type argument. The example below is fully 
   Set<Number> set = new HashSet<Number>();
   set.add(new Double(0));

Please have a look, how Set<E> interface is defined in the JDK.

As for the wildcards (? extends/super E), they are mostly needed, when you 
have generic objects being passed into/returned from methods. Remember that 
you cannot pass object, which is declared as Set<Double>, to a function that 
accepts a Set<Number> as an argument, but you can do it if the argument type 
is declared as Set<? extends Number>.

Without any aim to offend you, I would strongly recommend you revisiting the 
tutorial you mentioned.

> [collections] Support parametized classes with commons.collections.
> -------------------------------------------------------------------
>          Key: COLLECTIONS-110
>          URL:
>      Project: Commons Collections
>         Type: Bug

>  Environment: Operating System: other
> Platform: Other
>     Reporter: Colbert Philippe

> It's time to create a parallel version of commons.collections to support 
> parametized classes of each container class and abstract class.  It's not that 
> hard.  There is a 23 PDF document on Sun Java website describing in detail how 
> it should be done and what to watch out for.
> I already converted a few classes from commons.collection privately for my own 
> needs.  Once you get the hang of it, it's a rather quick process.
> I am even willing to volunteer my time to do some more but I need the 
> collaboration of some of the original programmers to watch over things.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message