When refactoring methods it is easy to introduce binary incompabilities (with previous versions of the code) in Java.
Consider changing a method to widen the type of its parameter to a parent interface:
void doSomething(String x);
// change it to
void doSomething(CharSequence c);
All the code that uses this method will continue to compile without changes, but it does require a re-compile (because the old binaries will fail with a MethodNotFoundError).
How about pulling a method up into a parent class. Will this require a re-compile?
// before
public class B extends A{
protected void x(){};
}
// after
public class A {
public void x(){};
}
public class B extends A{}
The method has been moved from B to the parent A. It has also changed visibility from protected to public (but that is not a problem).
Do I need to maintain a "binary compatibility wrapper" in B, or will it continue to work (automatically dispatch to the parent class)?
// do I need this ?
public class B extends A{
// binary compatibility wrapper
public void x(){ super.x(); }
}