Name: mc57594 Date: 05/21/97
Object is not a direct supertype of an interface. In other
words, if an interface type is searched for a declaration during lookup,
lookup does not proceed thence into Object; similarly, an interface that
happens to declare an abstract method with the same signature as a
method in Object is NOT overriding the method in Object!
However javac treats all interfaces as though they were implicitly
directly extending/implementing Object:
interface J {
void notify (); // error - overrides final method
void finalize () throws J; // error - wider 'throws' list
J clone (); // error - different return type
}
This interface is well-formed, but javac rejects it.
Similarly, the following code is illegal; however javac accepts it:
interface J {
}
class Test {
void f (J j) {
j.toString(); // OK - toString is a member of J
}
}
======================================================================
- relates to
-
JDK-4668238 compiler improperly complains about an interface "overriding" final Object meth.
- Closed