Community
Participate
Working Groups
public class GenericsArray1<T> { T[] theArray; public GenericsArray1( Class<T> clazz ){ theArray = (T[]) Array.newInstance( clazz, 10 ); //Compiler warning } public T get(int i){ return theArray[i]; } public static void main(String[] args){ GenericsArray1<Integer> t = new GenericsArray1<Integer>( Integer.class ); //GenericsArray1<Integer> t = new GenericsArray1<Integer>( int.class ); Object[] o = t.theArray; } } Javac shows the error "GenericsArray1.java uses unchecked or unsafe operations" in the constructor. It seems that since the commented line above throws a ClassCastException there should be a warning. Eclipse 3.1M5a doesn't show anything.
Javac shows the warning ( not error ) "GenericsArray1.java uses unchecked or unsafe operations" in the constructor.
Added GenericTypeTest#test634. Tuned CastExpression unsafe cast diagnosis for array cast types. Fixed
Verified in I20050510-0010