Bug 282420 - Type mismatch: cannot convert from List<Class> to List<Class<?>>
Summary: Type mismatch: cannot convert from List<Class> to List<Class<?>>
Status: VERIFIED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-03 23:18 EDT by kite CLA
Modified: 2009-08-04 04:45 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 kite CLA 2009-07-03 23:18:20 EDT
Build ID: I20090611-1540

Steps To Reproduce:
1.Create a java source file, switch JRE to IBM JDK 5.0,
Type this statement, List<Class<?>> defs = Arrays.asList(Object.class.getInterfaces());
2.JDT show error info for this statement,can not produce class file.
3.Switch JRE to Sun JDK, it's ok.


More information:
Comment 1 Kent Johnson CLA 2009-07-07 11:48:05 EDT
Tried this case with javac :

import java.util.*;
class X {
	void test(List<Class> list, List<Class<?>> list2) {
		list = list2;
		list2 = list;
	}
}


X.java:6: incompatible types
                list = list2;
                       ^
  required: java.util.List<java.lang.Class>
  found:    java.util.List<java.lang.Class<?>>
X.java:7: incompatible types
                list2 = list;
                        ^
  required: java.util.List<java.lang.Class<?>>
  found:    java.util.List<java.lang.Class>
2 errors

So why should the asList call work ?
Comment 2 Kent Johnson CLA 2009-07-08 15:08:06 EDT
Sorry I missed this the first time around.


In 1.5, Class.getInterfaces() was defined as :

public native Class[] getInterfaces();

In 6.0, it was defined as :

public native Class<?>[] getInterfaces();


So ensure you're using a JDK 6 VM if you expect this to work :

List<Class<?>> defs = Arrays.asList(Object.class.getInterfaces());
Comment 3 Srikanth Sankaran CLA 2009-08-04 04:45:49 EDT
Verified for 3.6M1