Why is it so easy to decompile Java code?

So, I just realized how easy it is to decompile Java code. I searched around the web and I can’t understand why it is so easy. Every time I google something like "Why can I decompose .class files?" or β€œWhy Java decompiles so easily,” all I get is links to software that can easily decompile my code. So, I turn to you at StackOverflow: why is it that Java can be converted back to easily readable source code, while C ++ and other languages ​​are not very friendly to decompilation?

thank

+47
java decompiling
Sep 16 '12 at 20:35
source share
2 answers

Since Java bytecode is closer (more like) to the source than to the assembly.

In particular, .class files include metadata for class names, method names, fields and parameter types, etc.

All Java decompilers (or .Net) need to do is look at the instructions in each method tera and turn them into the corresponding syntax constructs.

In contrast, native languages ​​such as C ++ do not contain metadata at all, so the decompiler must restore everything.

+55
Sep 16 '12 at 20:37
source share

Java is compiled into an intermediate form, the JVM bytecode, which stores a large amount of information contained in the Java source code. A language like C ++ is compiled into assembler code, which is outwardly very different from the source code and therefore harder to undo.

+21
Sep 16
source share



All Articles