Deep understanding of Java Virtual Machine-Chapter 10-early (compilation phase) optimization, deep understanding of virtual machines
Chapter 2 early (compilation period) Optimization
Javac compilation process:
1. parsing and filling the symbol table process
Lexical and syntax analysis converts the source code to a Token set. For example, the code "int a = B + 2" contains six tags: int a = B + 2
Fill symbol table
2. annotation Processor
3. Semantic Analysis and bytecode generation
The annotation check includes whether a variable has been declared before use, whether the data type between the variable and the value assignment can match, and an important action is called constant folding.
Data and control flow analysis further verifies the context logic of the program, it can check whether the program's local variables are assigned a value before use, whether each path of the method has a return value, and whether all the checked exceptions are correctly handled.
Syntactic sugar generics, variable length parameters, automatic packing/unpacking, etc.
The generic type in java only exists in the program source code. It is replaced with the original native type in the compiled bytecode, and the forced type conversion code is inserted in the corresponding place.
Bytecode generation