When we finish writing the Helloworld.java file, how does the computer know what we are going to do? Then it needs to be compiled (see article: JIT compilation), here is also a simple point to add:
1. Programming Language:
Programming languages are divided into high -level and low-level languages: C, C + +, Java, etc. are high-level languages; Machine and assembly languages are low-level languages. What does that have to do with compiling?
In a nutshell, compiling is the process of translating high-level languages that programmers know into low-level languages , which can be compiled by command Javac, and in contrast, there will be anti-compilation, turning the machine into a programmer 's understanding, In theory, the class file is turned into a Java file, but in fact it turns into a byte code that we can read, to analyze the principle behind the program running, anti-compilation is necessary.
2. Compiling
Next, compile, compile can be divided into front-end compilation and Back-end compilation , the former language-related, target machine-independent, the latter is related to the target machine, language-independent. In Java, compiling a. java file into a. class file is called a front-end compilation; compiling A. class file into a machine language is called a back-end compilation.
The bytecode in the. class file compiled by the front-end is an intermediate code with two important properties: easy to generate and easily translated into the language on the target machine.
Back-end compilation, the bytecode is interpreted as machine instructions, in order to improve performance and efficiency, the introduction of JIT technology, "hot Code" translated into machine instructions, optimized and cached for the next use. See: JIT-compiled articles
3. Anti-compilation
We're going to reverse-compile the local code to get a sense of its usefulness.
Have we ever wondered what class an Enum class is? What does an enum mean? Then you need to decompile:
Before anti-compilation:
Post-compilation:
After disassembly, the Enum class is a final modified class and inherits the Enum class under the Lang packet, so we know what's going on.
Another example:
The above two graphs are the two data types of the switch structure, what is the difference? See is not visible, anti-compilation will know:
By anti-compilation, we can know that the direct comparison of the integer type, the ASCII code of char types, will be converted to int type, the question is, what is the string type? By anti-compilation You will know that the string type is implemented through the equals () and hashcode () methods. Therefore,switch supports only one data type, that is, integer, and other data types will be converted .
Local variable type inference for 4.Java 10
March 21 Java 10 release, briefly describe the inference of its local variable type.
Post-compilation gets:
A comparison between the two pictures is a glance, what it looks like. Now it's all slowly changing to Java 8, so 10 get to know it first. We'll see you next time!
Reference: http://www.hollischuang.com/
Java Virtual Machines--compiling that little thing