Community
Participate
Working Groups
I'm using I20040428 with Cheetah04. This piece of code is compiled by Cheetah while javac will issue an "unchecked assignment" warning and needs "new Vector<T>()" instead. import java.util.Vector; public class A { <T> Vector<T> valuesOf(Hashtable<?, T> h) { return new Vector(); } }
This might be a similar problem... the code shown below compiles fine with Eclipse but issues an "[unchecked] unchecked cast to type java.util.Vector<java.lang.Object>" warning with javac. In constrast to the first example, this code looks valid to me... import java.util.Vector; public class B { Vector<Object> data; public void t() { Vector<Object> v = (Vector<Object>) data.elementAt(0); } }
Support added to diagnose unsafe returned value. Added regression test: GenericTypeTest#test176. Both testcases are issuing warnings: ---------- 1. WARNING in ...\A.java (at line 5) return new Vector(); ^^^^^^^^^^^^ Unsafe type operation: Should not return value of raw type Vector instead of type Vector<T>. References to generic type Vector<E> should be parameterized ---------- ---------- 1. WARNING in ...\B.java (at line 7) Vector<Object> v = (Vector<Object>) data.elementAt(0); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsafe type operation: Should not cast from Object to Vector<Object>. Generic type information will be erased at runtime ----------
Fixed