The inherently process-independent nature of Java features a structure that allows for reverse compilation. Java, through a compiler, transforms .java files into bytecode, resulting in .class files. However, engaging in reverse compilation can revert a .class file back to a .java file.
This operation is also possible in C#. The reverse compilation tools for C# are exceptionally well-designed, and in some cases, when decompiling code created by the user, the resulting code is even cleaner.
In the past, due to the possibility of source code being exposed, obfuscation programs were employed to make reverse-engineered source code more challenging to comprehend. Recently, with the increasing prevalence of open-source practices and the acceleration and complexity of business, the demand for obfuscation has been decreasing.
WhaTap Labs places a high emphasis on the significance of the developer who writes the code, rather than the code itself. The company does not prioritize obfuscation, as it does not attach great importance to the public release of the code. In fact, Watlabs has plans to disclose the performance analysis agent code.
Now, let's delve into Java decompilation.
Reverse compilation is employed when one wishes to examine someone else's code. There is no need to reverse compile one's own code.
For instance, in the code above, you might become curious about how the class named "Print" functions. In Eclipse, you can press F3 to examine the code, or in IntelliJ, you can use command+b (ctrl+b in the Windows version). If it's a class you've authored (in a .java file), it will directly navigate to the function's declaration. However, if it's not, the screen will display as follows.
The message "source not found" is displayed along with the Byte code of the corresponding class.
Unless you have a strong understanding of bytecode, comprehending its contents may be challenging. (Attempting to understand that code could be detrimental to mental well-being.)
In such cases, by decompiling the .class file using JD-GUI, you can view the corresponding .java code.
The print function of the Print class is designed to display the current time along with the string "Helloworld".
If you're curious about System.out.println here, you can discover more by delving into reverse compilation.
JD-GUI is the most widely used Java reverse compilation tool, renowned for its popularity, especially due to its GUI capabilities. JD-GUI is compatible with Windows, Linux, and OSX.
Key Features
There are a few limitations.
This is the execution on OSX. It's possible to see the reverse-compiled classes organized by packages within the JAR. Clicking on an underlined class will navigate to the decompiled Java source of that class. (This is only possible among decompiled classes within the JAR.)
JD-GUI supports filtered searching in reverse-compiled Java code.
What happens when you decompile a JAR file that has undergone obfuscation?
While reverse compilation is possible, reading the code is challenging due to the obfuscation process.
Obfuscated sources result in all variables and classes being replaced by meaningless strings such as a, b, c, d... The function names also appear as a, b, c, d... (I attempted to understand obfuscated code a few times, but it's also detrimental to mental health.)
The above code is an entry for the 2018 International Obfuscated C Code Contest (IOCCC). It is a compilable code that actually works. You can visit the website to see entries submitted each year.
The Green Team came to the realization that the smart home appliance market was not as promising as initially thought. Subsequently, they received a proposal to contribute to the operating system of a Set-Top Box (STB) for interactive television. Swiftly transitioning from the smart home appliance market to the Set-Top Box operating system market, the Green Team encountered challenges and ultimately faced failure in entering the market. As for Star7, its fate remains uncertain.
When compiling decompiled sources, it's essential to examine library references carefully. Compiling should include the referenced libraries to avoid errors even if the class has been fully restored to Java.
JD-GUI offers the advantage of supporting a GUI, making it convenient for standalone use. However, in scenarios where reverse compilation is necessary during the development process, using plugins is recommended. Finally, while reverse engineering tools can help understand the workings and structure of a program, leading to the creation of more refined code, it's crucial not to misuse these tools to exploit another developer's code.