Home  >  Article  >  Java  >  How to decompile java

How to decompile java

(*-*)浩
(*-*)浩Original
2019-12-04 10:20:145771browse

How to decompile java

What is decompilation?

The decompilation process is just the opposite of compilation, which is to restore the compiled programming language to the uncompiled state The state is to find the source code of the programming language. It is to convert the language that the machine can understand into the language that the programmer can understand.

Decompilation in Java language generally refers to converting class files into java files. (Recommended learning: java course)

With the decompilation tool, we can do many things. The most important function is that with the decompilation tool, we can Can read and understand the bytecode generated by the Java compiler. For example, we can gain insight into the principles behind Java syntax sugar.

Commonly used Java decompilation tools

Mainly introduces four Java decompilation tools: javap, jad and cfr as well as the visual decompilation tool JD-GUI

JAVAP

javap is a tool that comes with jdk. It can decompile the code and view the bytecode generated by the java compiler. The biggest difference between javap and the other two decompilation tools is that the files it generates are not java files, and they are not as easy to understand as the codes generated by the other two tools.

javap does not decompile the bytecode into a java file, but generates a bytecode that we can understand. In fact, the files generated by javap are still bytecodes, but programmers can understand them a little more. If you have some knowledge of bytecode, you can still understand the above code. In fact, it is to convert String into hashcode and then compare.

JAD

JAD is a relatively good decompilation tool. As long as you download an execution tool, you can decompile class files. Still the above source code, the content after decompilation using jad is as follows:

Command: jad.exe Decompilation.class will generate a Decompilation.jad file

CFR

JAD is very useful, but unfortunately it has not been updated for a long time, so it can only be replaced by a new tool. CFR is a good choice. Compared with JAD, its syntax may be slightly different. A little more complicated, but fortunately it can be used.

CFR will decompile modern Java features – Java 8 lambdas (Java beta 103 in Java and earlier versions), Java 7 String has been decompiled, but CFR is Completely written in Java 6.

JD-GUI

JD-GUI is a Java decompilation tool developed in C, developed by Pavel Kouznetsov, and supports Windows, Linux and Apple Mac Os three platforms. And provides the plug-in JD-Eclipse under the Eclipse platform.

JD-GUI is based on the GPLv3 open source license and is completely free for personal use. The main thing of JD-GUI is to provide visual operations. You can drag and drop files directly into the window. The rendering is as follows

How to decompile java

The above is the detailed content of How to decompile java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn