Changing a method that is declared abstract to no longer be declared abstract
does not break compatibility with pre-existing binaries.
Changing a method that is not declared abstract to be declared abstract will break compatibility with pre-existing binaries that previously invoked the method, causing an AbstractMethodError. If the example program:
class Super { void out() { System.out.println("Out"); } }
class Test extends Super {
public static void main(String[] args) {
Test t = new Test();
System.out.println("Way ");
t.out();
}
}
is compiled and executed, it produces the output:
Way Out
Suppose that a new version of class Super is produced:
abstract class Super {
abstract void out();
}
If Super is recompiled but not Test, then running the new binary with the existing binary of Test results in a AbstractMethodError, because class Test has no
implementation of the method out, and is therefore is (or should be) abstract. (An
early version of Java incorrectly produced the output:
Way
before encountering an AbstractMethodError while invoking the method out,
incorrectly allowing the class Test to be prepared even though it has an abstract
method and is not declared abstract.)