JVM class file format

java from coding to executionInsert picture description here

x.java generates x.class through javac command and x.class is
executed through java command. Load to memory through classloader. The code often needs to reference the java class library, so it also needs to be
loaded to the memory through the classloader. After the loading is completed, the bytecode interpreter or JIT will be called for interpretation or compilation. After the
compilation is completed, the execution engine starts execution. The
opposite of the execution engine is the operating system. And hardware

class file structure

type of data

u1 u2 u4 u8 and _info (table type)
The source of _info is the wording in the hotspot source code.
u means unsigned, u1 is one byte (binary 8 bits, hexadecimal 2 bits, such as CA), u2 is two words Section

View bytecode plug-in:
IDEA plug-in JClassLib

class structure

Insert picture description here
constant_pool_count is used to represent the constant number of the constant pool, where the constant pool is indexed from 1, because the 0th item is used for some data that points to the index value of the constant pool. Under certain circumstances, it means "do not reference any constant The meaning of "pool item".

Each constant in the constant pool is a table. The first bit at the beginning of the table structure is a tag of type u1, which represents which constant type the current constant belongs to.
Insert picture description here
Specific items, such as CONSTANT_Utf8_info, are as follows
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_33873431/article/details/112253734