Can I use WinMerge to compare *.class files?

5,963

I have spent the day writing a DLL plugin for Winmerge to do this - it isn't the world's greatest thing, but it gets the job done.

Takes the filename, splits it into directory and class name, then calls javap for each class file. It is rather slow unfortunately (javap's fault I'd say).

I have put the DLL here:

https://www.dropbox.com/s/6hywu64zzj248t1/displayclassfiles.dll?dl=1

Absolutely no licence, warranty, etc. No trojans or virii either. I will get around to cleaning up the source and putting it up somewhere (probably with the winmerge project people).

Create a "MergePlugins" directory where your winmerge executable is and put the dll in there. It is automatically activated on *.class files.

The hardest part was working out how to launch javap, windows programming is just so awful.

It would be nice if winmerge compared the files before unpacking them to see if they are different - that would save a bit of time. Maybe this can be accomplished in the plugin somehow but as I said I really just hacked this together as quick as I could.

Oh I should mention you will need javap on your path.

EDIT: Source code is here: https://www.dropbox.com/s/gberx85pdcdlor2/unpackjavaclassfiles%20source.7z?dl=1 Built using visual studio 2005 - Adapted from DisplayBinaryFiles plugin which is available with winmerge source package.

Share:
5,963
RonK
Author by

RonK

Updated on September 18, 2022

Comments

  • RonK
    RonK almost 2 years

    I used to work with BeyondCompare and it was able to compare *.class files by configuring it to run a decompiler before comparison.

    Is there something like that for WinMerge? Or a plug-in that can do it instead?

  • RonK
    RonK over 12 years
    Thanks - I missed the notification about this answer, i just saw it now. I really appreciate your effort - I'll test it ASAP :)
  • Gary Tsui
    Gary Tsui over 10 years
    to enable automatic diffing (upon double clicking), do this (Plugins > Automatic Unpacking) - WinMerge 2.14.0
  • Wayne Uroda
    Wayne Uroda over 10 years
    @GaryTsui thanks, but what I mean is that in the list view (say you compare a whole folder of class files) it will show class files as different, even though upon unpacking they are identical. I think this comes about because they can have binary differences (due to recompilation etc) however the method/field signatures have not changed. When comparing two binary APIs for example, you have to check every different class manually, when you double click on it you will be met with "the files are identical" or similar, even though they were marked as different in the list!
  • ahmednabil88
    ahmednabil88 over 8 years
    great trick .. you save my night :)
  • Alireza Fattahi
    Alireza Fattahi about 3 years
    The links seems to be broken :(
  • Wayne Uroda
    Wayne Uroda about 3 years
    @AlirezaFattahi I updated the links