为什么反编译Java代码这么容易? [英] Why is it so easy to decompile Java Code?
问题描述
所以我刚刚意识到反编译Java代码是多么容易。我一直在网上搜索,我似乎无法弄明白为什么这么容易。每当我谷歌为什么我可以解除 .class
文件?或者为什么Java反编译如此容易,我得到的只是软件的链接,可以轻松地反编译我的代码。所以我转向你StackOverflow:为什么Java可以转换回易于阅读的源代码而C ++和其他语言对反编译不是很友好?
So I've just realized how easy it is to decompile my Java code. I've been searching around the net and I can't seem to figure out WHY its so easy. Every time I google something like "Why can I decomilple .class
files?" or "Why does Java decompile so easily", all I get is links to software that can easily deompile my code. So I turn to you StackOverflow: why is it that Java can be converted back to easlily readable source code while C++ and other languages aren't very friendly to decompiling?
谢谢
推荐答案
因为Java字节码比汇编更接近(更相似)源。
Because Java byte-code is closer (more similar) to the source than assembly.
特别是, .class
文件包括类名,方法名,字段和数组的元数据。参数类型等...
所有Java(或.Net)反编译器需要做的是查看每个方法体中的指令,并将它们转换为适当的语法结构。
In particular, .class
files include metadata for classnames, method names, field & parameter types, etc...
All a Java (or .Net) decompiler needs to do is look at the instructions in each method body, and turn them into the appropriate syntactic constructs.
相比之下,像C ++这样的本地语言根本不包含任何元数据,因此反编译器需要重建所有内容。
By contrast, native languages like C++ do not include any metadata at all, so the decompiler needs to reconstruct everything.
这篇关于为什么反编译Java代码这么容易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!