7

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
  • 1,540

3 Answers3

11

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).

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.

Source, prebuilt DLL, and instructions here: https://gitlab.com/wayneuroda/winmerge-unpack-java-class-files

Wayne Uroda
  • 255
  • 4
  • 10
1

If comparing disassembled JVM bytecode (see my other answer) is not enough, maybe decompiling to Java source code might be more helpful…

After learning about the "currently undocumented" Plugins.xml (Plugins in the improved plugin system) as an alternative to sct and dll plugins, I have sucessfully "created" a plugin decompiling Java *.class files using procyon Java Decompiler in WinMerge 2.16.30.0:

  1. Create directory %APPDATA%\WinMerge\MergePlugins, if it doesn't exist.
  2. Create file %APPDATA%\WinMerge\MergePlugins\Plugins.xml, if it doesn't exist.
    • Use C:\Program Files\WinMerge\MergePlugins\Plugins.xml as template removing <plugin> elements.
  3. Insert a custom <plugin> with your path\to\procyon-decompiler.jar:
<?xml version="1.0"?>
<plugins>
  <plugin name="MyDecompileJavaClass">
    <event value="FILE_PACK_UNPACK" />
    <description value="My JVM class decompiler with Procyon. &#xD;&#xA;Arguments: Command line options passed to the java command." />
    <file-filters value="\.class$" />
    <is-automatic value="false" />
    <unpacked-file-extension value=".class.java" />
    <extended-properties value="ProcessType=Decompilation;MenuCaption=My Decompile Java Class" />
    <arguments value="A:\path\to\procyon-decompiler.jar" />
    <unpack-file>
      <command>cmd /c java -jar ${*} "${SRC_FILE}" > "${DST_FILE}"</command>
    </unpack-file>
  </plugin>
</plugins>
  1. Reload plugins (WinMerge menu command).
  2. If necessary, adjust the path to Procyon JAR (arguments) in WinMerge plugin settings.
  3. Use the new plugin for unpacking/comparing in WinMerge.
fheub
  • 186
  • 1
  • 9
0

The DecompileJVM plugin DisassembleJVM has been added in WinMerge 2.16.15 - 2021-09-20. Look for "Disassemble JVM Bytecode" in the list of plugins.

It is an unpacker plugin allowing you to compare JVM bytecode disassembled with javap.

fheub
  • 186
  • 1
  • 9