-
Bug
-
Resolution: Unresolved
-
P4
-
7u45, 8
JLS 7 allows an inherited concrete method of a superclass to "override" an inherited interface method with an override-equivalent signature (8.4.8.4). This is the case _even if_ the concrete signature is not a subsignature of the interface signature; a special unchecked warning is supposed to occur.
JLS 8 cleans up overriding by preventing the inheritance of overridden methods, but always requiring that the overrider have a subsignature of the overridden method (8.4.8.1).
javac (7 and 8) follows neither of these, simply inheriting both methods and allowing them to coexist.
class C<T> { void m(T arg) {} }
interface I { void m(Class arg); }
class D extends C<Class<String>> implements I {}
// expected (7): "overriding" occurs
// expected (8): error -- conflicting inherited methods
// actual: error -- abstract method not overridden
abstract class E extends C<Class<String>> implements I {}
// expected (7): "overriding" occurs
// expected (8): error -- conflicting inherited methods
// actual: no error, but no bridge method
Since the JLS 7 feature is strange (perhaps motivated by extra migration compatibility?) and was never implemented, it doesn't make much sense to implement it now. It could be treated as a JLS 7 spec bug ("fixed" by the changes in 8). But the JLS 8 behavior should be implemented correctly.
JLS 8 cleans up overriding by preventing the inheritance of overridden methods, but always requiring that the overrider have a subsignature of the overridden method (8.4.8.1).
javac (7 and 8) follows neither of these, simply inheriting both methods and allowing them to coexist.
class C<T> { void m(T arg) {} }
interface I { void m(Class arg); }
class D extends C<Class<String>> implements I {}
// expected (7): "overriding" occurs
// expected (8): error -- conflicting inherited methods
// actual: error -- abstract method not overridden
abstract class E extends C<Class<String>> implements I {}
// expected (7): "overriding" occurs
// expected (8): error -- conflicting inherited methods
// actual: no error, but no bridge method
Since the JLS 7 feature is strange (perhaps motivated by extra migration compatibility?) and was never implemented, it doesn't make much sense to implement it now. It could be treated as a JLS 7 spec bug ("fixed" by the changes in 8). But the JLS 8 behavior should be implemented correctly.
- relates to
-
JDK-8030143 8.4.8.4: Error for override-equivalent declared/inherited methods?
-
- Open
-
-
JDK-5059679 name clash not reported for interface inheritance
-
- Closed
-