Bug 82460

Summary: [1.5][compiler] Unnecessary@Override warning on implemented interface method
Product: [Eclipse Project] JDT Reporter: Tobias Widmer <tobias_widmer>
Component: CoreAssignee: 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 CLA 2005-01-10 06:40:03 EST
20050104:

Steps to reproduce:
- Create interface ITest<A extends Map & List, B extends Collection, C>
  with method A getA() returning null
- Implement interface in a test class
- Add @Override annotation to the overridden getA()
-> Unnecessary compiler problem that method must override method from 
superclass
-> Message should rather say supertype instead of superclass
Comment 1 Jerome Lanneluc CLA 2005-01-11 09:06:09 EST
Test case:
public interface I<A> {
	A getA();
}
class X<A> implements I<A> {
	@Override
	public A getA() {
		return null;
	}
}
Comment 2 Markus Keller CLA 2005-02-08 13:08:04 EST
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() { }
}
Comment 3 Philipe Mulet CLA 2005-03-07 16:52:02 EST
We will stick to the spec.