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??
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With