In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to understand the compilation period of Java language". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The compilation time of the Java language is actually an uncertain process, because it may refer to the process of a front-end compiler (the front end of the compiler) converting .java files into .class files, or it may refer to the process of the back-end runtime compiler (JIT compiler) of the virtual machine converting bytecode into machine code. It may also be the process of compiling .java files directly into native machine code using a static advance compiler (AOT compiler).
Front-end compiler: convert .java source files into bytecode .class files. For example, the incremental compiler (ECJ) in Sun's javac,Eclipse JDT.
JIT just-in-time compiler: converts bytecode into machine code, such as Hotspot VM's C1 and C2 compilers.
AOT compiler: directly compile .java files into native machine code, such as GNU Compiler For Java (GCJ), Excelsior JET.
The virtual machine design team focuses on performance optimization in the back-end just-in-time compiler so that class files that are not generated by javac can also enjoy the benefits of compilation optimization. However, javac has done a lot of optimization measures for the Java language coding process to improve the coding style and efficiency of programmers. Quite a few of the new Java syntax features are implemented by the syntax candy of the compiler, rather than supported by the underlying changes of the virtual machine. It can be said that in Java, even the optimization process of the compiler at run time is more important for the running of the program, while the optimization of the front-end compiler at compile time is more closely related to the program coding.
Java grammatical sugar
Each language will more or less provide some syntax candy to facilitate programmers' code development, although these syntax candy will not provide substantial functional improvements, but they can improve efficiency or syntax rigor. Or it can reduce the chance of coding errors. However, there is also a view that grammar sugar is not necessarily beneficial, adding and using a large number of syntax containing "sugar" is easy for programmers to rely on. In short, syntax candy can be seen as some of the compiler's "tricks", using them can improve efficiency, but we should also understand the principles behind them.
Generics and type erasure
Generics in Java language are different, they only exist in the program source code, have been replaced with native types in the compiled bytecode file, and the forced conversion code has been inserted in the corresponding place. Therefore, for run-time Java, ArrayList and ArrayList are of the same type, so generics technology is actually a grammatical sugar of the Java language. This generic implementation method is called type erasure, and generics based on this method are called pseudo-generics. However, the generic information is still retained in the metadata, which is the fundamental basis on which we can obtain the parameterized zone type by reflection. For example, getGenericSuperclass () can get a parent class with generics.
Automatic boxing, unpacking and traversal cycle
From a technical point of view, syntactic sugars such as automatic boxing, unboxing, and traversing loops are much simpler to implement and ideologically than generics, but they are the most commonly used grammatical sweets in the Java language.
Conditional compilation
The implementation of conditional compilation in Java is also a syntax candy of Java language. According to the true or false Boolean constant value, the compiler will eliminate the unestablished code blocks in the branch. This work will be completed in the stage when the compiler removes the syntax sugar.
This is the end of the content of "how to understand the compilation period of the Java language". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.