What processes does javac compilation include?
The java compilation process is mainly divided into the following steps:
1. Lexical analysis : Convert the characters in the source code (various keywords, variables, etc.) into a set of tokens, the smallest unit of program writing for a single character, and token is the smallest unit of the compilation process.
2. Syntax analysis: Construct a collection of tokens into an abstract syntax tree. Each node of the syntax tree represents a syntax structure in the code (such as package, type, interface, modifier, etc.).
3. Fill the symbol table: The symbol table is a table composed of a set of symbol addresses and symbol information. The exit from the process of filling the symbol table is a pending list containing the top-level nodes of each abstract syntax tree (and package-info.java).
4. Plug-in annotation processor processes annotations: The annotation processor can add, delete, or modify any element of the abstract syntax tree. Therefore, whenever the annotation processor modifies the syntax tree, steps 1, 2, and 3 will be re-executed until the annotation processor no longer modifies the syntax tree. Each cycle process is called a Round.
5. Semantic analysis: Context-sensitive review of source programs that are correct in syntax tree structure.
Annotation check: including whether variables are declared, whether variables and assignment types match, etc., and constant folding.
Data and control flow analysis: further verification of program context logic. Including whether variables are assigned values before use, whether methods have return values, whether exceptions are handled correctly, etc.
6. Decode syntax sugar: Convert advanced syntax (such as generics, variable parameters, unboxing, etc.) into basic syntax structures. These are not supported when the virtual machine is running. Advanced syntax.
7. Generate bytecode: Convert the information in the syntax tree and symbol table into bytecode and write it to the disk, while performing a small amount of code addition and conversion work.
Most of the above content is excerpted from: "In-depth Understanding of Java Virtual Machine" -- Zhou Zhiming
Recommended tutorial: "java tutorial"
The above is the detailed content of What processes does javac compilation include?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool