3 ms·
Forcing the use of something like @Override wouldn't have mattered because dispatch is dynamic -- it would only trigger a compilation error when recompiling fro
by pron 4y ago
Forcing the use of something like @Override wouldn't have mattered because dispatch is dynamic -- it would only trigger a compilation error when recompiling from source. At runtime, if the methods have a different (and incompatible) return type then the original method would be called because the JVM does allow overloads that differ by return types, but the Java language doesn't, so already-compiled code would work as before, but it wouldn't compile from source (that's a source incompatibility, which is not as important in Java as binary compatibility). If the methods do have a matching signature to the default ones, then they will be called when the interface method is invoked, as overrides of the default methods. If, additionally, their behaviour is not one that conforms to the new interface's specification, that could be a problem. That's why a corpus analysis is needed, to see how frequently such methods were added in subclasses.