Bug 208995 - Static method hides method from instance when using generics
Summary: Static method hides method from instance when using generics
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-07 05:33 EST by Hendrik Heins CLA
Modified: 2007-12-11 06:59 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (4.42 KB, patch)
2007-11-07 15:38 EST, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Heins CLA 2007-11-07 05:33:58 EST
Please look at the following code :

public class A {
	
	public void doSomething(List aList) {}
	
	public void doSomethingElse(List<Integer> aList) {}
}

public class B extends A {

	public static void doSomething(List aList) {}
	
	public static void doSomethingElse(List<String> aList) {}
}

In class B eclipse marks method doSomething(..) with this error message:

"This static method cannot hide the instance method from A"

According to JLS this is correct:

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8.2

But the same should happen with method doSomethingElse(..) in class B, because after type erasure this method hides doSomethingElse(..) from class A.

Compiling class B with javac from Sun JDK (1.5.09) produces a compiler error.

Interestingly after changing the type parameter of aList in Method B.doSomethingElse(List<String> aList) to Integer eclipse produces the same compiler error as in the first example.
Comment 1 Kent Johnson CLA 2007-11-07 15:38:25 EST
Created attachment 82363 [details]
Proposed patch
Comment 2 Kent Johnson CLA 2007-11-08 11:16:00 EST
Released into HEAD for 3.4M4

Added MethodVerifyTest.test149()
Comment 3 David Audel CLA 2007-12-11 06:59:34 EST
Verified for 3.4M4 using build I20071210-1800.