siom79 / japicmp

Comparison of two versions of a jar archive
https://siom79.github.io/japicmp
Apache License 2.0
712 stars 107 forks source link

Overriding default methods in interfaces reported as binary incompatible. #312

Closed jake-at-work closed 2 years ago

jake-at-work commented 2 years ago

I am confused as to why overriding the methods from one interface in another between releases is detected as a binary incompatible change.

I am trying to deprecate methods inherited by poor choices in inheritance so that we avoid implementations using those methods and can later drop the bad inheritance.

Effectively we are going from this:

interface Something extends SomethingElse {
    default void doSomething() {}
}

interface SomethingElse {
    default void doSomethingElse() {}
}

to:

interface Something extends SomethingElse {
    default void doSomething() {}
    @Deprecated
    @Override
    default void doSomethingElse() {}
    default void doSomethingBetter() { doSomethingElse(); }
}

interface SomethingElse {
    default void doSomethingElse() {}
}
It is reported as: Error Class Something: Is not binary compatible
Error Method Something.close(): Is not binary compatible
METHOD_NEW_DEFAULT
Error Method Something.doSomethingBetter(): Is not binary compatible
METHOD_NEW_DEFAULT
Error Method Something.doSomethingElse(): Is not binary compatible
METHOD_NEW_DEFAULT
ANNOTATION_DEPRECATED_ADDED

I would appreciate any insight into this issue and how best to deal with it.

siom79 commented 2 years ago

Finally found issue and fixed it.

Fixed: 0.15.5