Bug 186496

Summary: Code compiles in Eclipse but not with Sun JDK
Product: [Eclipse Project] JDT Reporter: Glen <glen.a.ritchie>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2.2   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Glen CLA 2007-05-11 01:53:52 EDT
The following code will compile in Eclipse(3.2.2) but not with the latest Sun JDK(build 1.6.0_01-b06) I can't tell which is right, but if the Sun JDK follows the spec exactly then the Eclipse JDT compiler contains a bug, otherwise it's probably a Sun bug. Hoping someone can clear the matter up.

JDT version: 
Version: 3.2.2.r322_v20070104-R4CR0Znkvtfjv9-
Build id: M20070212-133

Output:
Roo!
1.0
2.0
class [Ljava.lang.Object;

Expected:
The code should not compile ( if we assume Sun's JDK is correct )

The error given by the Sun compiler is:
----------------------------------------------------
test.java:8: cannot select from a type variable
                System.out.println(T[].class);
                                      ^
1 error
----------------------------------------------------


TEST CODE:
----------------------------------------------------
class test
{
	public static <T> void myFunc(T[] test)
	{
		for (T t : test) 
		  System.out.println(t);
		System.out.println(T[].class);
	}
	public static void main(String []args)
	{
		System.out.println("Roo!");
		Float f[] = new Float[] { 1.0f, 2.0f };
		myFunc(f);
	}
}
Comment 1 Philipe Mulet CLA 2007-05-11 03:28:38 EDT
this is a dup of bug 181270, which got addressed in 3.3M7.

*** This bug has been marked as a duplicate of bug 181270 ***