Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...