简体   繁体   English

如何在Oracle的JVM中实现引用?

[英]How are references implemented in Oracle's 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? 在搜索有关如何在Java中实现引用变量的解释时,我遇到了这样一个问题: Java中的引用变量内部有什么? In there was a comment by Samuel_xL saying that specifying the vendor name would be a better question. 在Samuel_xL的评论中说,指定供应商名称将是一个更好的问题。 So my question is that how an instance variable in implemented in Oracle JVM? 所以我的问题是如何在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. 我知道引用包含告诉JVM如何访问对象的位。 But how is it structured?? 但它是如何构建的?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM