Bug 90775

Summary: [1.5][compiler] Missing unchecked warning
Product: [Eclipse Project] JDT Reporter: Mohan Radhakrishnan <javatech>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: mlists
Version: 3.1   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Mohan Radhakrishnan CLA 2005-04-08 05:52:44 EDT
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.
Comment 1 Mohan Radhakrishnan CLA 2005-04-08 05:54:16 EDT
Javac shows the warning ( not error ) "GenericsArray1.java uses unchecked or 
unsafe operations" in the constructor.
Comment 2 Philipe Mulet CLA 2005-04-29 09:37:32 EDT
Added GenericTypeTest#test634.
Tuned CastExpression unsafe cast diagnosis for array cast types.
Fixed
Comment 3 Olivier Thomann CLA 2005-05-11 11:47:08 EDT
Verified in I20050510-0010