Bug 90775 - [1.5][compiler] Missing unchecked warning
Summary: [1.5][compiler] Missing unchecked warning
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-08 05:52 EDT by Mohan Radhakrishnan CLA
Modified: 2005-05-11 11:47 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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