Bug 82460 - [1.5][compiler] Unnecessary@Override warning on implemented interface method
Summary: [1.5][compiler] Unnecessary@Override warning on implemented interface method
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-10 06:40 EST by Tobias Widmer CLA
Modified: 2005-03-07 16:52 EST (History)
1 user (show)

See Also:


Attachments

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