Alexey Varlamov 写道: > 2006/8/29, Spark Shen <[EMAIL PROTECTED]>: >> Krzysztof Sobolewski 写道: >> > Spark Shen wrote: >> > >> > >> >> 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. >> >> >> > >> > Well, I created a new EnumSet class in completly unrelated >> environment... So >> > it is perfectly possible that there's a classpath conflict >> somewhere. I >> > can't verify that because don't have the Harmony build here :) >> > >> > BTW: another experiment revealed that >> > EnumSet<? extends Enum<E>> set = (EnumSet<? extends >> Enum<E>>)collection; >> > compiles without warnings. No matter how much I think I understand >> generics, >> > there's always something that surprises me ;) >> > >> Conceptually speaking, I think EnumSet<? extends Enum<E>> still has >> potential pitfall: >> >> In the signature of addAll(Collection<? extends E> collection) method, ? >> denotes subclass of E. >> While in EnumSet<? extends Enum<E>>, ? denotes subclass of Enum<E>. But >> consider the relationship >> between E and Enum<E>, E is subclass of Enum<E>. So, we can not >> guarantee that subclass of E is definitely >> subclass of Enum<E>. > > Hmm, as E is a subclass of Enum<E>, subclasses of E definitely have > Enum<E> among ancestors ;) Yes, you are right. And I made a wrong judgement here. :-P
The actual statement I want to judge is that: E is subclass of Enum<E>. So, we can not guarantee that subclasses of E(? extends E) is definitely compatible with subclasses of Enum<E>(? extends Enum<E>). Since the input collection is of type <? extends E>, cast it to <? extends Enum<E>> seems suspicious. > >> >> Correct me if I am wrong. >> >> Best regards >> > -KS >> > >> > >> >> >> -- >> Spark Shen >> China Software Development Lab, IBM >> >> >> --------------------------------------------------------------------- >> Terms of use : http://incubator.apache.org/harmony/mailing.html >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > Terms of use : http://incubator.apache.org/harmony/mailing.html > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Spark Shen China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]