harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spark Shen <smallsmallor...@gmail.com>
Subject Re: [classlib] Sun compiler change?
Date Mon, 28 Aug 2006 12:48:39 GMT
Krzysztof Sobolewski 写道:
> 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? :)
Did you (refer to thread [app] ant with ecj) put

Eclipse compiler JAR on Ant's
execution classpath to execute the javac task.

If so, may be that's why 
It always gives you "unchecked cast" warning, no errors.

Best regards

>> 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...
> BTW:
> 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... ;)
> -KS

Spark Shen
China Software Development Lab, IBM

Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message