如何在Oracle的JVM中实现引用? [英] How are references implemented in Oracle's JVM?

查看:124
本文介绍了如何在Oracle的JVM中实现引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索有关如何在Java中实现引用变量的解释时,我遇到了这个问题:
Java中的引用变量内部有什么内容?
Samuel_xL发表评论称,指定供应商名称将是一个更好的问题。
所以我的问题是如何在Oracle JVM中实现实例变量?它是指向地址的指针吗?我知道引用包含告诉JVM如何访问对象的位。
但它是如何构造的?

While searching for an explanation on how a reference variable is implemented in Java I came across this question: What's inside a reference variable in Java? In there was a comment by Samuel_xL saying that specifying the vendor name would be a better question. So my question is that how an instance variable in implemented in Oracle JVM? Is it a pointer to an address? I know that a reference holds bits that tell the JVM how to access the object. But how is it structured??

推荐答案

从我能够确定的,存储了对象引用或者作为一个名为 oop (普通对象指针)或 narrowOop 的类型,具体取决于JVM是否使用压缩对象指针或不。 oop 是一个包装指向Java对象的C ++类,而 narrowOop 是32位无符号的必须转换为适当指针才能访问对象的整数;他们没有内部结构。你可以在这里找到声明: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/oops/oopsHierarchy.hpp

From what I've been able to determine, object references are stored either as a type called oop (ordinary object pointer) or narrowOop, depending on whether the JVM is using compressed object pointers or not. An oop is a C++ class that wraps a pointer to a Java object, and a narrowOop is a 32-bit unsigned integer that has to be converted into a proper pointer in order to access the object; they have no internal structure. You can find the declarations here: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/oops/oopsHierarchy.hpp

这篇关于如何在Oracle的JVM中实现引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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