我如何判断为什么/如何两个类文件不同?

huangapple go评论65阅读模式
英文:

How can I tell why/how two class files are different?

问题

我正在尝试重新创建一些旧的源代码。我有两个类,一个来自我的新源代码,一个来自丢失的源代码。这两个类都将反编译为相同的源代码。然而,对这些类进行比特级别的比较仍然显示出差异。如何确定是什么导致了这些差异?

GC_

英文:

I am trying to recreate some old source. I have two classes, one from my new source and one from the lost source. The both classes will decompile to identical source. However, a bit level compare of the classes still shows differences. How do tell what causes these differences?

GC_

答案1

得分: 1

如果你想找出两个类文件之间的区别,我建议使用Krakatau反汇编器-roundtrip模式。这将把类文件转换成一个可读的文本格式,仍然一一映射到类文件的精确二进制编码。然后,你可以比较生成的文本文件,以查看其中的差异。

英文:

If you want to find out what is different between the two classfiles, I'd recommend using the Krakatau disassembler in -roundtrip mode. This will convert the classfiles to a human readable text format that still maps 1:1 to the exact binary encoding of the classfile. Then you can diff the resulting text files to see what is different.

答案2

得分: 0

我发现只使用javap非常有帮助。

我对两个类都运行了这个命令:

javap -version -l -v -p -c -s -sysinfo ClassName.class > temp.txt

然后我比较了这两个文件。这揭示了我要找的差异。这是一种行号的问题。我也发现eclipse的反编译器很有帮助。

英文:

I found just using javap to be very helpful.

I ran this command for both classes:

javap -version -l -v -p -c -s -sysinfo ClassName.class > temp.txt

Then I compared the two files. This uncovered the difference I was looking for. It was a line number thing. I found eclipse's decompiler helpful, too.

huangapple
  • 本文由 发表于 2020年8月5日 21:21:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63266144.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定