Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the structure of the jvm class file

Shulou Source: shulou.com Published: 2022-05-31 12:32:25 09月16日 Update

In this article Xiaobian for you to introduce in detail "how the structure of the jvm class file is", the content is detailed, the steps are clear, the details are handled properly, I hope that this article "how the structure of the jvm class file is" can help you solve your doubts, following the editor's ideas slowly in-depth, let's learn new knowledge together.

Class file structure

A class file is a set of binary streams in 8-bit byte base units, and each data item is arranged in a compact order in the class file.

The class file format uses pseudo code similar to the C language structure to store data, in which there are only unsigned numbers and tables.

Unsigned numbers belong to the basic data type, and u1, 2, 4 and 8 bytes represent unsigned numbers of 1 byte, 2 bytes, 4 bytes and 8 bytes respectively.

Unsigned can be used to describe numbers, index references, quantity values, or string values according to utf-8 coding.

A table is a compound data type consisting of multiple unsigned or other tables as data items, and tables usually end with "_ info"

The byte order in the class file is Big-Endian (large end mode and small end mode)

Big-end mode means that the low bit of data is stored in the high address of memory, while the high bit of data is stored in the low address of memory.

The small end mode means that the low order of the data is stored in the low address of the memory, while the high order of the data is stored in the high address of the memory.

The first four bytes of the class file are called Magic Number, and it is used to determine whether the file is a class file accepted by a virtual machine.

Constant pool

A constant pool is a repository of class files.

The constant pool mainly stores two types of constants, literal quantities (Literal) and symbolic references (Symbolic Reference).

Literals are similar to constant concepts at the Java language level, such as text strings, constant values declared as final, etc.

Symbol reference belongs to the category of compilation principle.

a. Fully qualified names of classes and interfaces

b. Names and description symbols such as fields

c. Method name and descriptor

Access flag

Magic number-the "constant" constant ends, followed by two bytes representing an access flag (access_flags), which is used to identify access information such as a class or interface hierarchy. (whether class is a class or interface, whether it is a public type, whether it is an abstract type, whether it is declared as final)

After reading this, the article "what is the structure of the jvm class file" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: File data byte constant structure symbol memory address pattern type number interface article flag representative low order content name big end character Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Linux Apple Xiaomi macOS