C
changzhouwang
Isn't it strange to see a compilation warning about the following code
-------code-----
ArrayList<String> a1 = new ArrayList<String>(); ...
ArrayList<String> a2 = (ArrayList<String>)a1.clone();
-------warning (in eclipse) -----
Type safety: The cast from Object to ArrayList<String> is actually
checking against the erased type ArrayList
-------end-------
And
-------code-----
EventListener l=...;
Class<EventListener> class1 = (Class<EventListener>)l.getClass();
-------warning (in eclipse) -----
Type safety: The cast from Class<capture-of ? extends EventListener> to
Class<EventListener> is actually checking against the erased type Class
-------end-------
Without the explicit conversion, there will be compilation error, due
to the way JDK 1.5 implements generics. That's understandable.
However, I don't see why we need the warning message if there is not
possible way to get rid of it. Any comments?
-czwang
-------code-----
ArrayList<String> a1 = new ArrayList<String>(); ...
ArrayList<String> a2 = (ArrayList<String>)a1.clone();
-------warning (in eclipse) -----
Type safety: The cast from Object to ArrayList<String> is actually
checking against the erased type ArrayList
-------end-------
And
-------code-----
EventListener l=...;
Class<EventListener> class1 = (Class<EventListener>)l.getClass();
-------warning (in eclipse) -----
Type safety: The cast from Class<capture-of ? extends EventListener> to
Class<EventListener> is actually checking against the erased type Class
-------end-------
Without the explicit conversion, there will be compilation error, due
to the way JDK 1.5 implements generics. That's understandable.
However, I don't see why we need the warning message if there is not
possible way to get rid of it. Any comments?
-czwang