Java Reference
In-Depth Information
T id(T x) {...}
}
interface I<T> {
T id(T x);
}
class D extends C<String> implements I<Integer> {
public String id(String x) {...}
public Integer id(Integer x) {...}
}
This is also illegal, since D.id(String) is a member of D , D.id(Integer) is declared in D ,
and:
• The two methods have the same name, id
D.id(Integer) is accessible to D
• The two methods have different signatures (and neither is a subsignature of
the other)
D.id(String) overrides C<String>.id(String) and D.id(Integer) overrides I.id(Integer)
yet the two overridden methods have the same erasure
8.4.8.4. Inheriting Methods with Override-Equivalent Signatures
It is possible for a class to inherit multiple methods with override-equivalent signatures
8.4.2 ) .
It is a compile-time error if a class C inherits a concrete method whose signature is a sub-
signature of another concrete method inherited by C . This can happen if a superclass is
generic, and it has two methods that were distinct in the generic declaration, but have the
same signature in the particular invocation used.
Otherwise, there are two possible cases:
• If one of the inherited methods is not abstract , then there are two subcases:
♦ If the method that is not abstract is static , a compile-time error occurs.
♦ Otherwise, the method that is not abstract is considered to override, and there-
fore to implement, all the other methods on behalf of the class that inherits it.
If the signature of the non- abstract method is not a subsignature of each of the
other inherited methods, a compile-time unchecked warning occurs unless sup-
pressed by the SuppressWarnings annotation (§ 9.6.3.5 ).
Search WWH ::




Custom Search