Search code examples
javadecompiling

Any tools for comparing decompiled classes to source code?


For arguements sake, you've got some compiled .class files, and some source .java files.

You're not convinced that the class files were actually built from the same revision of those source files that you have (for example someone else created those classes but didn't check in the source code).

I know what you're thinking, a developers nightmare. However, are there any tools that can assist in decompiling class files and comparing those against source files and flagging up any differences such as missing methods etc?

I've done this manually, decompiled a class, and compared each line to the source code, there were significant differences in business logic. I have several hundred files to do this for, are there any tools to help?


Solution

  • I'd compile the .java files you have. Then decompile those .class files and the original .class files you have. A script should be able to get you this far. Then you can compare the resultant .java files with a tool like Meld, BeyondCompare or simply diff -ur on the command line. Running them through the same decompiler should at least give you better commonality so there's less noise in your diffs. Good luck with that though, that doesn't sound like fun any way you slice it.