Summary: | [1.5][compiler] Eclipse gives a "name clash" error while javac accepts the code | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Zorzella Mising name <zorzella> |
Component: | Core | Assignee: | Kent Johnson <kent_johnson> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P3 | ||
Version: | 3.2 | ||
Target Milestone: | 3.2 RC2 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Zorzella Mising name
2006-04-13 01:46:54 EDT
I don't know if it's the same root, but an error also happens when using @Override with static methods. This code has both conditions: import java.util.Collection; public class Parent { public static void error (Collection c){} public static void error2 () {} public static class Child extends Parent { public static void error(Collection<String> c) {} @Override public static void error2() {} } } Reproduced first problem in latest. Second issue is expected behavior. Static methods are not overriding. Javac1.6 says: X.java:9: method does not override a method from its superclass @Override public static void error2() {} ^ 1 error We should not detect name clashes between inherited static methods. The following case shows that the instance methods do cause a name clash: import java.util.Collection; class Parent { static void staticCase1(Collection c) {} static void staticCase2(Collection<String> c) {} void instanceCase1(Collection c) {} void instanceCase2(Collection<String> c) {} } class Child extends Parent { static void staticCase1(Collection<String> c) {} static void staticCase2(Collection c) {} // @Override is an error for instanceCase1 // name clash: instanceCase1(Collection<String>) in Child and // instanceCase1(Collection) in Parent have the same erasure, yet // neither overrides the other void instanceCase1(Collection<String> c) {} @Override void instanceCase2(Collection c) {} } case2 is allowed for compatibility reasons, but case1 is a name clash. Added MethodVerifyTest 85 Verified with I20060427-1600 for 3.2RC2 |