Bug 79143 - [1.5] no compiler warnings for types in Collection's <T> T[] toArray(T[] a)
Summary: [1.5] no compiler warnings for types in Collection's <T> T[] toArray(T[] a)
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-21 08:14 EST by mike andrews CLA
Modified: 2005-01-14 09:19 EST (History)
0 users

See Also:


Attachments

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