Summary: | [1.5][compiler] Unnecessary@Override warning on implemented interface method | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tobias Widmer <tobias_widmer> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED WONTFIX | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | markus.kell.r |
Version: | 3.1 | ||
Target Milestone: | 3.1 M6 | ||
Hardware: | PC | ||
OS: | All | ||
Whiteboard: |
Description
Tobias Widmer
2005-01-10 06:40:03 EST
Test case: public interface I<A> { A getA(); } class X<A> implements I<A> { @Override public A getA() { return null; } } No, the compiler's current behavior is correct with respect to the specs. The javadoc of @interface Override also only talks about "superclass" and not about "supertype". The JLS3 preview says (9.6.1.4 Override) explicitly: "Note that if a method overrides a method from a superinterface but not from a superclass, using @Override will cause a compile-time error." IMO, the specs are seriously broken in this matter, since they make a difference between interface and abstract class methods: interface I { void run(); // delete and everything's fine } abstract class C { abstract void run(); // delete and you'll get a compile error } class X extends C implements I { @Override public void run() { } } We will stick to the spec. |