Bug 79143

Summary: [1.5] no compiler warnings for types in Collection's <T> T[] toArray(T[] a)
Product: [Eclipse Project] JDT Reporter: mike andrews <mikea>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description mike andrews CLA 2004-11-21 08:14:21 EST
in the java.util.Collection class, there is a method "<T> T[] toArray(T[] a)".
the compiler doesn't seem to be checking for generic type conformance. example
code SHOULD generate a compiler warning or error, but doesn't:

Set<MyType> set = new HashSet<MyType>();
Object[] array = new Object[set.size()];
set.toArray(array);
Comment 1 Philipe Mulet CLA 2005-01-14 09:19:32 EST
Why would it generate an error ?

FYI the following code also compiles ok with javac.
import java.util.*;

public class X {

	void foo() {
	Set<X> set = new HashSet<X>();
	Object[] array = new Object[set.size()];
	set.toArray(array);
	}
}