siom79 / japicmp

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

Questions about the mechanism of binary compatibility checks #369

Closed WencongLiu closed 5 months ago

WencongLiu commented 7 months ago

Hello everyone, I am a loyal user of the japicmp plugin. I am very curious about the underlying principles of how japicmp checks for binary compatibility and would like to inquire about the implementation details.

I usually use the japicmp maven plugin. At https://siom79.github.io/japicmp/MavenPlugin.html, you can see that the plugin considers different code changes to have varying levels of source compatibility and binary compatibility. For instance, CLASS_NOW_ABSTRACT is not only source incompatible but also binary incompatible.

I would like to consult how japicmp determines whether two versions of a jar are binary compatible. I think it's unlikely that japicmp constructs concrete test cases and actually runs the Class bytecode in the jar to determine binary compatibility. I suspect that the japicmp plugin simply compares the changes in code between the two jar versions and matches them against predefined compatibility rules to determine if the jars are binary compatible.

I would like to ask if my view is correct. If anyone knows about the underlying principles of japicmp's binary compatibility checks, I would appreciate your insights. Thank you all.

siom79 commented 5 months ago

Hello,

basically the chapter about "Binary Compatibility" in the "Java Language Specification" (see here) is consulted. If in doubt, concrete test cases are constructed and rules are derived. These rules are implemented and checked against the classes and its members.

WencongLiu commented 5 months ago

Thanks for the reply.😄 @siom79