Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive BC break when a method changes from abstract to default #411

Open
garydgregory opened this issue Jan 7, 2025 · 1 comment

Comments

@garydgregory
Copy link

garydgregory commented Jan 7, 2025

Hi All:

According to the JLS 13.4.16. abstract Methods:

Changing a method that is declared abstract to no longer be declared abstract does not break compatibility with pre-existing binaries.

But japicmp reports a break when this happens in Apache Commons Digester:

git clone https://github.com/apache/commons-digester.git
cd commons-digester
git checkout 338f5195f67ee4dd23492963bc15739fd4ae1e13
mvn clean package japicmp:cmp -DskipTests

yields:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.041 s
[INFO] Finished at: 2025-01-07T16:38:30-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.23.0:cmp (default-cli) on project commons-digester3: There is at least one incompatibility: org.apache.commons.digester3.ObjectCreationFactory.getDigester():METHOD_ABSTRACT_NOW_DEFAULT,org.apache.commons.digester3.ObjectCreationFactory.setDigester(org.apache.commons.digester3.Digester):METHOD_ABSTRACT_NOW_DEFAULT -> [Help 1]

In this case, the change is from abstract to default in an interface.

Or am I missing something?

I am using:

openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.13+0, mixed mode, sharing)

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 17.0.13, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@17/17.0.13/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "15.2", arch: "aarch64", family: "mac"

TY!

@siom79
Copy link
Owner

siom79 commented Jan 10, 2025

Hi,
the JLS says in 13.5.7:

Adding a default method, or changing a method from abstract to default, does not break compatibility with pre-existing binaries, but may cause an IncompatibleClassChangeError if a pre-existing binary attempts to invoke the method.

Therefore I have configured the Change METHOD_ABSTRACT_NOW_DEFAULT as incompatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants