Bug 186496 - Code compiles in Eclipse but not with Sun JDK
Summary: Code compiles in Eclipse but not with Sun JDK
Status: RESOLVED DUPLICATE of bug 181270
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-11 01:53 EDT by Glen CLA
Modified: 2007-05-11 03:28 EDT (History)
0 users

See Also:


Attachments

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