Possible Duplicate:
Is `List<Dog>` a subclass of `List<Animal>`? Why aren’t Java’s generics implicitly polymorphic?
public abstract class AbstractServerSession<E extends AbstractPacket> {
[...]
packet = (E) PacketFactory.getPacket(packetClazz);
I get this error that IMHO makes no sense:
Type mismatch: cannot convert from AbstractPacket to E
How he cannot convert if I explicitly stated that E
is a child of AbstractPacket
?
I can add a cast
packet = (E) PacketFactory.getPacket(packetClazz);
but then of course I get this warning:
Type safety: Unchecked cast from AbstractPacket to E
So what is <E extends AbstractPacket>
for?
EDIT: as requested
public static final AbstractPacket getPacket(Class<? extends AbstractPacket> clazz)
Thanks for your time!