Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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??

like image 760
zindarod Avatar asked Nov 13 '22 00:11

zindarod


1 Answers

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

like image 153
Joni Avatar answered Nov 14 '22 21:11

Joni