harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Sobolewski <jez...@interia.pl>
Subject Re: [classlib] Sun compiler change?
Date Mon, 28 Aug 2006 10:46:29 GMT
Spark Shen wrote:

>> As far as I understand generics, SomeClass<A> and SomeClass<B>, where
>> extends A, *are* incompatible (per the spec). Generic types are not
>> polymorphic.
>> The problematic line IMO should read:
>> EnumSet<? extends E> set = (EnumSet<? extends E>)collection;
> Do you mean to change the problematic line into the above statement? I
> have tried this already, but this type of cast will also give a
> compilation error.

That's odd. I used a compiler this time and could not reproduce it (with
javac 1.5.0_08-b03 and quick-and-dirty from-the-scratch EnumSet impl). It
always gives me "unchecked cast" warning, no errors. Maybe I should check
out Harmony sources? :)

> And I did not find a way to suppress the unchecked warning while
> compilation succeed.

Maybe @SuppressWarnings("unchecked")? If you're absolutely sure it's OK...

EnumSet<?> set = (EnumSet<?>)collection;
seems to compile fine, but I'm not sure it's enough for you :)

>> [1] I guess this is in addAll() or its friends?
> I guess 'its friends' refers to removeAll, containsAll, and retainAll.
> :-)   But all its friends have different signature as addAll
> boolean     addAll(*Collection<? extends E>* c)
> boolean     containsAll(*Collection<?>* c)
> boolean     removeAll(*Collection<?>* c)
> boolean     retainAll(*Collection<?>* c)
> I guess you know why they are different.
> So, in the implementation of all its friends, same problem is not
> encountered.

Oh, yeah... Who'd remember all that... ;)

View raw message