Skip to content

removing a method from an unstable interface breaks compatibility checks for implementing classes. #421

@hgschmie

Description

@hgschmie

Consider this interface:

@Unstable
interface Foo {
    default void one() {
       ... do something
    }

    void two();
}

and an implementing class

class Bar implements Foo {
    void two() {
       ... do something else
    }
}

(@Unstable is an annotation that we ignore for japicmp using @Unstable in the exclude config for the maven plugin).

We shipped this code for a while. It turns out that the "One" default method needs to go away. removing it, results in

WARNING: Incompatibility detected: Requires semantic version level MAJOR: JApiMethod [oldMethod=Bar.one(), newMethod=n.a., returnType=JApiReturnType [oldReturnTypeOptional=void, newReturnTypeOptional=void, changeStatus=REMOVED], getCompatibilityChanges()=[JApiCompatibilityChange{type=METHOD_REMOVED}]]

(or similar).

That was surprising. My assumption was, because the "Foo" interface is unstable and the method is not overridden in the implementing class, removing it would be no problem.

Adding the @Unstable annotation temporarily to class Bar is worse, because now the class "disappears" from the japicmp run and I get different errors.

Is this "works as designed"? How do I mark an interface default method in an unstable interface so that I can actually remove it without breaking japicmp?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions