Deep Java programming: Java byte code

Source: Internet
Author: User
Tags zip

Java programmers rarely notice the results of a program's compilation. In fact, the Java byte Code provides us with very valuable information. In particular, when debugging troubleshooting Java performance Issues, the results of the compilation allow us to understand more deeply how to improve the efficiency of program execution, and so on. In fact, the JDK makes it very easy to study Java byte code. This article explains how to use the tools in the JDK to view the interpretation of Java byte code, which mainly includes some of the following:

L Java class-decomposing device--JAVAP

How Java byte code enables programs to avoid program memory errors

How to improve the efficiency of program execution by analyzing byte code

• decompile Java byte code with third-party tools

Java class factorization--JAVAP

Most Java programmers know that their program is not compiling the cost machine code. In fact, the program is compiled into intermediate byte code, which is interpreted by the Java virtual machine. However, few programmers pay attention to byte code because the tools they use do not encourage them to do so. Most Java Debugging tools do not allow Single-step byte code debugging. These tools either display the source code or do not display anything.

Fortunately, the JDK provides a Java class-JAVAP, a command-line tool. JAVAP The byte code provided by the file (. Class) given by the class name to print out a readable version of these classes. By default, Javap prints out common fields, methods, constructors, and static initial values within a given class.

1. The specific usage of JAVAP

Syntax: JAVAP < options > < class name ....

These options include:

Parameters Meaning
B JAVAP in backward-compatible JDK 1.1
C Decompile the code to print out the Java Virtual Machine directives for the methods in each given class. When this option is used, all methods, including private and protected methods, are decompile
Classpath <pathlist> Indicates where to find the user's class file. This option value overrides the missing path and the path defined by the CLASSPATH environment variable. The path given here is a list of directories and zip files, with elements in Unix ":", and ";" in Windows. Separated. To add some directories or zip files to find without overwriting the default system classpath, use the CLASSPATH environment variable, which is the same as the compiler's-classpath.
Extdirs <dirs> Overwrite installation extension directory
Help Display Help information
J<flag> Pass <flag> directly to the operating system
L On the basis of the original print information, increase the row number and the local variable table
Public Show only public classes and their members
Protected Show protected/public classes and their members
Package Show package protected/public class and its members (default)
Private Show all classes and their members
S Print Internal Type tags
Bootclasspath <pathlist> Overwrite class file locations loaded by the boot class loader
Verbose The size of the print stack, the number of local variables and parameters for the method. If verifiable, printing error causes

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.