JarDiff - create a diff of the public API of two JAR files

I've written a simple shell script to generate "signatures" of all the *.class files in two JAR files and compare these with diff. The output is pretty well usable to spot the (sometimes accidental) differences between two versions of the same library.

I've tested the script on Ubuntu and Mac OS X, but it should work well on most Unix/Linux platforms. I've found it interesting that javap in OpenJDK was significantly faster than the javap in the Sun (now Oracle) JRE. Smile

Running the script is pretty trivial:
jardiff.sh file1.jar file2.jar [output.diff]

The third parameter is optional. If not specified, the diff will be saved as jardiff_yyyy-mm-dd_hh-mi-ss.diff and the various date and time related fields are replaced with their actual values.

AttachmentSize
jardiff-1.0.0.sh4.91 KB
jardiff-1.1.0.sh6.06 KB
jardiff-1.2.0.sh7 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

JarDiff v1.1.0

List of changes:
  • Added optional command for post processing javap's output. By default this command is a sort. This helps in cases where the order of class properties and functions changes between different versions of the containing JAR. This can happen if the class is automatically generated via some tool (eg. HyperJAXB). The order of a generated class's properties and functions might change regardless whether there's any "real" change to them (ie. in the property's/function's definition).

JarDiff v1.2.0

List of changes:
  • Removed dependency on the existence of the TMPDIR environment variable.
  • Refactored output into two parts:
    • diff of class lists (i.e. class names that are only present in one of the JAR files)
    • diff of common classes (as before)
  • both diffs show only the differences, common filenames/lines are skipped
  • a few minor bugfixes and optimizations here and there