Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's in the class file?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is in the class file". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is inside the class file".

Property sheet

First of all, the property sheet is used to supplement the information, for example, he can continue to supplement the information of the class file, that is, the last paragraph above, as well as the information of the field and the method. So it appears in different locations, and the additional information will be different.

Now we have a "simple" understanding of the "main" content, the reason to be simple, to understand the main, because it holds too much additional information.

The structure of the property table consists of 2 bytes of attribute name index, 4 bytes of attribute content length, and 1 byte of attribute information.

According to the category of attributes, they can be divided into class file properties, field table properties and method table properties.

Class file property InnerClass

Save the relationship between the main class and the inner class

SourceFile

Record the name of the source file that generated this Class file

Method table property Code

After the code in the body of the Java program method is processed by the Javac compiler, the bytecode instructions are stored in the Code attribute. Not all method tables must have this attribute, and the Code attribute does not exist for methods in interfaces or abstract classes.

There is also a property sheet in the code property. (nesting dolls), which includes

LineNumberTable source code and generated bytecode line number mapping table the mapping relationship between variables in LocalVariableTable stack frames and source code variables ExceptionTable exception table

The Exceptions property enumerates the exceptions thrown after the throws keyword

MethodParameters

Define the parameter information of the method

Field Table property ConstantValue

This property is used to assign values to static variables of the field. Valid only if the field is declared as static. When compiling, if the Javac compiler encounters a primitive type or String type variable modified by both static and final, it will initialize the field directly in the ConstantValue property. That's what we call constants. If there is no final decoration, or if it is not a primitive type and a String type, it is initialized when the class initialization method executes

Common property Deprecated

The Deprecated property is used to indicate that a class, field, or method is deprecated

Thank you for your reading, the above is the content of "what is in the class file", after the study of this article, I believe you have a deeper understanding of what is in the class file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report