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?
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
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:
%APPDATA%\WinMerge\MergePlugins
, if it doesn't exist.%APPDATA%\WinMerge\MergePlugins\Plugins.xml
, if it doesn't exist.
C:\Program Files\WinMerge\MergePlugins\Plugins.xml
as template removing <plugin>
elements.<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. 
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>
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
.