Bug 282420

Summary: Type mismatch: cannot convert from List<Class> to List<Class<?>>
Product: [Eclipse Project] JDT Reporter: kite <yipeng97>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED NOT_ECLIPSE QA Contact:
Severity: critical    
Priority: P3 CC: srikanth_sankaran
Version: 3.5   
Target Milestone: 3.6 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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