Search code examples
javasvndecompilingfilecompare

Decompiling java class files and comparing with svn


We have normal java files residing in the SVN. We have made some changes in those files , but it happens that , those files are lost (they are not in SVN). But we have the class files that are generated using the newly changed files.

Can we use the class files , decompile them and compare it against SVN. What is the easiest way to do it?

There are about 400 changed files. So comparing one by one is not feasible.

I am looking for any tool or scripts.

Also is there any decompiler , that would decompile a whole folder at one go?

Thanks


Solution

  • For decompiling use JAD, most commonly used tool. Comparing is a bit tricky though. I would suggest the following scenario:

    1. Grab the latest source code from SVN
    2. Build it
    3. Decompile it (!)
    4. Take your compiled classes that include some modifications but you don't have sources
    5. Decompile them as well
    6. Compare both decompiled sources directories

    Why compiling and decompiling the original source codes? Because JAD produces pretty good results, but it will never generate the exact same sources that were used. So if you want to avoid headaches when comparing original sources and decompiled ones (and pinpoint the actual differences quickly), you have to compare two JAD outputs rather than original source and synthetic JAD output.

    I hope having two directory structures to compare won't be a problem for you. You can use Total Commander on Windows or various utilities/scripts on Linux, like:

    $ diff -r dir1 dir2