开发者

Any tools for comparing decompiled classes to source code?

开发者 https://www.devze.com 2023-02-17 20:12 出处:网络
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 t

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, th开发者_运维知识库ere were significant differences in business logic. I have several hundred files to do this for, are there any tools to help?


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.


Hmm, if you have the source code and want to check if the binaries are built from the source code you have, why don’t you just compile the source code you have and see if the result matches the binaries you have?


You can directly compare the .class files and decompile/view it in .java format if you used beyondcompare application

and add the extra file formats to it (http://www.scootersoftware.com/download.php?zz=kb_moreformats_win)

by following this steps (http://www.scootersoftware.com/download.php?zz=kb_moreformats)

then use the application in normal way to compare folders/jars that contains .class files


(Although this is an old thread I still would like to mention some tools that remained unmentioned)

Grigsoft offers 2 handy tools for comparing source code. http://www.grigsoft.com/index.htm

  • Compare It! for comparing source code of 2 files. It will highlight the changes
  • Synchronize It! for comparing source code of 2 directory trees.

Furthermore, IntelliJ IDE has some built-in tools. You can select 2 files in the tree, right click and then select "Compare Two Files".


There are many comparison tools which effectively finds difference between two files, so I'd like to suggest you to use BeyondComapare. you can visit http://www.scootersoftware.com/, As I'm Java Developer, I've been using since many years.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号