Bug 210912 - [compiler] compiler should warn if array is instantiated with suptype of declaring type
Summary: [compiler] compiler should warn if array is instantiated with suptype of decl...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-26 06:17 EST by Benno Baumgartner CLA
Modified: 2007-11-26 12:23 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2007-11-26 06:17:07 EST
I20071113-0800

Given:
package test;
public class Test {
	
	public static interface IFace {}
	public static class MyFace implements IFace {}
	public static class HisFace implements IFace {}
	
	public static void main(String[] args) {
		IFace[] faces= new MyFace[10];
		faces[0]= new HisFace();
	}
}
1. Run as java application
Is:
 Exception in thread "main" java.lang.ArrayStoreException: test.Test$HisFace
	at test.Test.main(Test.java:10)
Should:
 A compiler warning (error)(potential programming problem) should be generated at new MyFace[10] telling me that I should use IFace instead.

I wonder how many such bugs we have...