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

False positive on SUPERCLASS_REMOVED? #277

Closed chrisvest closed 3 years ago

chrisvest commented 3 years ago

When a public class ceases to extend a package-private class, it is flagged as a SUPERCLASS_REMOVED incompatibility.

I'm not sure this is correct since the super-classes was package-private, and thus not visible or accessible.

Is this a false positive, or is there a subtlety that I've missed?

This was observed in https://github.com/netty/netty/pull/10872

siom79 commented 3 years ago

The Java Language Specification says in chapter 13.4.4:

If a change to the direct superclass or the set of direct superinterfaces results in any class or interface no longer being a superclass or superinterface, respectively, then linkage errors may result if pre-existing binaries are loaded with the binary of the modified class. Such changes are not recommended for widely distributed classes.

See also the example in the JLS. If together with the mere superclass also a protected member that the child class accesses is removed, a VerifyError at runtime is thrown.