存储器中参考变量和对象的逻辑结构/细节? [英] logical structure/details of a reference variable and object in the memory?

查看:85
本文介绍了存储器中参考变量和对象的逻辑结构/细节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一堂课:

class Class1
{
   int i = 1;
}

我们有一个变量:

Class1 ob1 = new Class1();

  • 存储在变量ob1中的引用本身是否存储引用Class1对象的信息?
  • 存储Class1的堆部分是否存储Class1类型的信息?
  • 此信息在逻辑上看起来如何?是像application1.Class1这样的字符串,还是对某些引用类型池的引用?
    • Does a reference itself stored in a variable ob1 store the information that it refers to an object of Class1?
    • Does the part of the heap where Class1 is stored store the information that it is of Class1 type?
    • How does logically looks like this information? It's a string like application1.Class1 or a reference to some reference types pool?
    • 如果您可以推荐此类信息的来源,我将不胜感激,因为我无法在参考书中找到它.

      If you can recommend the source of such information I'll be very grateful for providing it I can't find it in the reference book.

      推荐答案

      存储在变量ob1中的引用本身是否存储信息 它指向Class1的对象?

      Does a reference itself stored in a variable ob1 store the information that it refers to an object of Class1?

      .引用变量ob1仅存储其指向的对象的引用.应用程序(或JVM)已经知道有关该对象的信息.

      NO. Reference variable ob1 stores only the reference of the object it points to. And the information about that object is already known to the application (or JVM).

      存储Class1的堆部分是否存储信息 它是Class1类型的吗?

      Does the part of the heap where Class1 is stored store the information that it is of Class1 type?

      .有关正在加载的类的信息存储在此链接
      中所指定 对于它加载的每种类型,Java虚拟机必须在方法区域中存储以下类型的信息:

      NO. The information about class being loaded is stored in method area. As specified in this link
      For each type it loads, a Java virtual machine must store the following kinds of information in the method area:

      • 类型的完全限定名称
      • 类型的直接超类的完全限定名称(除非类型是接口或类java.lang.Object,两者都不具有超类)
      • 类型是否为类或接口
      • 类型的修饰符(public,abstract,final的某些子集)
      • 任何直接超级接口的完全限定名称的有序列表
      • The fully qualified name of the type
      • The fully qualified name of the type's direct superclass (unless the type is an interface or class java.lang.Object, neither of which have a superclass)
      • Whether or not the type is a class or an interface
      • The type's modifiers ( some subset of` public, abstract, final)
      • An ordered list of the fully qualified names of any direct superinterfaces

      此信息在逻辑上看起来如何?这是一个像 是application1.Class1还是对某些引用类型池的引用?

      How does logically looks like this information? It's a string like application1.Class1 or a reference to some reference types pool?

      在Java类文件和Java虚拟机中,类型名称始终存储为完全限定的名称.例如,包java.lang中Object类的全限定名表示为 java/lang/Object . 在方法区域中,完全限定的名称可以用设计者选择的任何形式和数据结构表示.

      Inside the Java class file and Java virtual machine, type names are always stored as fully qualified names. For example, the fully qualified name of class Object in package java.lang is representated as java/lang/Object. In the method area, fully qualified names can be represented in whatever form and data structures a designer chooses.

      这篇关于存储器中参考变量和对象的逻辑结构/细节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆