Direct references and symbolic references in the JVM

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_43719015/article/details/102770169
In the JVM, the class begins to be loaded into the virtual machine memory, up to unload a memory, its entire life cycle, including: loading, validation, preparation, parsing, initialization, use and uninstall the seven stages. The analytical phase is a virtual machine that is the constant pool of symbolic references replaced by a direct reference to the process.

Symbol references

1. The symbol references (Symbolic References): Symbol reference to a certain set of symbols described in the referenced, literal symbols may be in any form, can be unambiguous target as long as the target can be used. For example, it appears to CONSTANT_Class_info, CONSTANT_Fieldref_info, CONSTANT_Methodref_info other types of constants in the Class file. Symbol reference has nothing to do with the memory layout of the virtual machine, the goal is not necessarily referenced loaded into memory. In Java, a class will be compiled into a java class file. At compile time, java class does not know the actual address of the referenced class, you can only use symbolic references instead. For example org.simple.People class references org.simple.Language class, the class at compile time People do not know the actual memory address Language class, it can only use the symbol org.simple.Language (assuming that this is, of course, practice is ) is represented by the constant address Language classes similar to CONSTANT_Class_info be represented. Various virtual machine implementation of the memory location may vary, but they can accept symbolic references are the same, because the literal form of symbolic references clearly defined in the Java Virtual Machine specification Class file format.

Direct reference

2. Direct reference:
direct reference may be
(1) a direct pointer to the target (for example, point "Type" [] Class object, class variables, class methods may direct reference is a pointer to the method area)
(2) relative partial shift amount (for example, point to an instance variable, direct reference to the offset are examples of methods)
(3) a positioning indirectly to handle certain
direct reference is the layout of the virtual machines and associated, in the same virtual reference different symbol translated directly on the machine instances cited are generally not the same. If you have a direct reference to that target reference must have been loaded into the memory.

Guess you like

Origin blog.csdn.net/weixin_43719015/article/details/102770169