Java--the symbol reference and direct reference of the JVM

Source: Internet
Author: User
Tags instance method

During the class loading process in the JVM, during the parsing phase, the Java virtual Opportunity replaces the symbolic reference in class two-level data with a direct reference.

1. Symbol reference (symbolic References):

A symbol reference describes a target in a set of symbols, which can be any form of literal, as long as it can be used without ambiguity in the target. For example, in a Class file it appears as constants of type Constant_class_info, Constant_fieldref_info, Constant_methodref_info, and so on. The symbolic reference is independent of the memory layout of the virtual machine, and the referenced target does not necessarily load into memory. In Java, a Java class will be compiled into a class file. At compile time, the Java class does not know the actual address of the referenced class, so it can only be substituted with symbolic references. For example, the Org.simple.People class refers to the Org.simple.Language class, and at compile time the people class does not know the actual memory address of the Language class, so only the symbolic org.simple.Language is used (assuming this is, of course, actually by a C-like Onstant_class_info represented) to represent the address of the language class. The memory layouts implemented by various virtual machines may be different, but they can accept a consistent symbol reference because the literal form of the symbol reference is clearly defined in the Java Virtual Machine specification's class file format.

2. Direct reference: A direct reference can be (1) A pointer to a target directly (for example, to a "type" "Class object", a class variable, a direct reference to a class method may be a pointer to a method area) (2) A relative offset (for example, pointing to an instance variable, The direct reference to the instance method is offset) (3) a direct reference to a handle that can be indirectly anchored to the target is related to the layout of the virtual machine, and the same symbolic reference is generally not the same as the direct reference that is translated on the different virtual machine instances. If there is a direct reference, the referenced target must already be loaded into memory.

Java--the symbol reference and direct reference of the JVM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.