How is reference to java object is implemented?

前端 未结 5 1606
刺人心
刺人心 2020-12-07 02:40

Is pointer is just used for implementing java reference variable or how it is really implemented? Below are the lines from Java language specification

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 03:28

    You can actually go and get the source code from here: http://download.java.net/jdk6/source/

    The short answer to your question is: yes, there is a pointer to a memory location for your java variables (and a little extra). However this is a gigantic oversimplification. There are many many many C++ objects involved in moving java variables around in the VM. If you want to get dirty take a look at the hotspot\src\share\vm\oops package.

    In practice none of this matters to developing java though, as you have no direct way of working with it (and secondly you wouldn't want to, the JVM is optimized for various processor architectures).

提交回复
热议问题