JAVA program decompilation

Source: Internet
Author: User
Tags bit set

JAVA program decompilation
Nowadays, JAVA is widely used in the world. It is widely used in the production of INTERNET databases, multimedia, CGI, and dynamic web pages. In 1999, the demand for JAVA programmers in the United States exceeded C ++ for the first time!
Recently, I have analyzed some JAVA programs and learned about JAVA decompilation. The following describes what I know and hopes to help JAVA enthusiasts.
JAVA adopts a program structure called "byte encoding", which can be divided into two types: small programs (embedded in HTML files) and applications (directly executed in command state. Regardless of the structure, once compiled using the JAVAC command, it becomes an executable file with the same name as the CLASS extension. Such files are unreadable code.
After reading SUN's JDK (JDK1.1.3) documentation, I found a JAVAP File (EXE) that is said to be Decompiling JAVA. The file is located under JDKBIN, after following the instructions, I was disappointed that this "decompilation" only allowed to decompile the Data Zone (definition) of the JAVA program, and reference several methods and classes.
Here I use a simple example to illustrate the problem.
The JAVA source code hello_java.java is as follows:
Import java. applet .*;
Import java. awt .*;
Public class hello_java extends Applet
{
Public void paint (Graphics g)
{
G. drawString ("Hello Java! ", 20, 20 );
}
}
Decompilation command: javap-c-package-public-private hello_java hello. java
The decompilation result (hello. java) is as follows: (for the selection parameters of the javap command, see the instructions for use. Here-c indicates that Decompilation is selected)
Compiled from hello_java.java
Public synchronized class hello_java extends java. applet. Applet
/* ACC_SUPER bit set */
{
Public void paint (java. awt. Graphics );
Public hello_java ();
Method void paint (java. awt. Graphics)
0 aload_1
1 ldc #1
3 bipush 20
5 bipush 20
7 invokevirtual #6
10 return
Method hello_java ()
0 aload_0
1 invokespecial #5 () V>
4 return
}
The above results show that the decompilation fails to fully translate the source program, such as the statement g. drawString ("Hello Java! ", 20, 20); No. As the program volume increases, more JAVA statements cannot be compiled. Therefore, this decompilation program can only serve as a reference.
Thanks to the INTERNET, I quickly found a JAVA decompilation "free software", http://www.inter.nl.net/users/H.P.van.Vliet/mocha.htm through YAHOO.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.