In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the class file knowledge points of java". In the daily operation, I believe that many people have doubts about the knowledge points of java class files. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the knowledge points of java class files?" Next, please follow the editor to study!
I. contents of class file
Second, the content explains the magic number
The function of magic (magic number) is to identify whether the file type is a class file, and the magic number of a class file is 0xCAFEBABE.
When JVM tries to load a file into memory, it will first determine whether the class file has a "signature" that JVM thinks is acceptable, that is, JVM will first read the first 4 bytes of the file to determine whether the 4 bytes are "0xCAFEBABE". If so, JVM will think that the file can be loaded and used as a class file.
Version number
Minor_version and major_version are used to mark which version of the Java compiler the class file was compiled by (jdk1.6,1.7,1.8, etc.).
Class files compiled by a lower version of the Java compiler can run on a higher version of the virtual machine, that is, backward compatibility, but the virtual machine cannot execute more than its own version of the class file, even if the high version of the class file is exactly the same as the lower version of the class file except the version number.
Constant pool
Constant_pool (constant pool) is mainly used to store literal constants (literal) and symbolic constants in Class.
Literal constants include string constants in Class and values declared as final.
Symbolic constants mainly include: the fully qualified name of the class, the name and descriptor of the member variable, the name and descriptor of the method.
The constant pool consists of several constant tables, and each constant table stores a constant. For example, the int constant table stores int type constants, and the string type constant table stores all String type constants. There were 11 kinds of constant scale before Java 7, and 3 kinds of constant scale were added since Java 7.
Access flag bit
Used to represent the access rights and underlying properties of a class or interface.
Access_flags is used to save the access flags of Class and Interface, including whether the Class access qualification type is one of public, protected, private, whether final, Class of abstract, and so on.
Class index, parent index, and interface index
This_class (class index) is used to determine the fully qualified name of the class
Super_class (parent) is used to determine the fully qualified name of the parent class
Interfaces (Interface Index) is used to determine the fully qualified names of all interfaces implemented by this class. Their values point to the corresponding constants in the constant pool.
Member variable
Fields (member variables) is used to hold all member variables in Class, including static variables and instance variables.
All member variables in Class are stored in the form of a table, which stores the access flag bit, variable name index, variable descriptor index, variable attributes and other information of member variables. It is important to note that member variables inherited from the parent class are not included in fields.
Method
Methods (method) is used to hold all methods declared in Class, including the static method and the instance method. All the methods in Class are also stored in the form of a table, and the stored information is mainly: method access flag bits, method name index, method descriptor index, method properties and other information. If the method of the parent class is not overridden by the child class, the method of the parent class will not appear in the methods of the child class.
Attribute
Attributes (property) is used to hold detailed and specific information about member variables or methods in Class.
Each field or method can contain a property sheet that describes the details of the member variable or method. An attribute consists of multiple property sheets, each containing a specific type of property. The most common attribute types are as follows:
III. Schematic diagram of document structure
At this point, the study of "what are the class file knowledge points of java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.