siom79 / japicmp

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

Changes report includes unchanged properties, e.g. class file format #353

Open banszelj opened 1 year ago

banszelj commented 1 year ago

When the library (0.17.1) generates list of (binary incompatible or all) changes, it lists also some unchanged properties, like unchanged class file format or unchanged superclass.

I think unchanged properties should be skipped, in the same way as e.g. unchanged methods are skipped, so that the problematic changes are highlighted.

Example

Old version:

package com.example;

public class Example {

    private Object value;

    public Example(Object value) {
        this.value = value;
    }

    public Object getValue() {
        return value;
    }

}

New version (new method + incompatible change of constructor):

package com.example;

public class Example {

    private Object value;

    public Example(int value) {
        this.value = value;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

}

Reported binary incompatible changes using java -jar japicmp-0.17.1-jar-with-dependencies.jar -b -o example-old.jar -n example-new.jar:

Comparing binary compatibility of C:\Temp\example-new.jar against C:\Temp\example-old.jar
***! MODIFIED CLASS: PUBLIC com.example.Example  (not serializable)
        ===  CLASS FILE FORMAT VERSION: 55.0 <- 55.0
        ===  UNCHANGED SUPERCLASS: java.lang.Object (<- java.lang.Object)
        ---! REMOVED CONSTRUCTOR: PUBLIC(-) Example(java.lang.Object)