Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, a tid bit... calling the constructor of an object does not allocate it. In bytecode, the initialization <code>new Object()</code> is expressed as something to the effect of...</p> <pre><code>new java/lang/Object invokespecial java/lang/Object &lt;init&gt;()V </code></pre> <p>The <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.new" rel="nofollow"><code>new</code></a> instruction takes care of allocating the space and acquiring a reference to the yet <em>uninitialized</em> object, while the <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.invokespecial" rel="nofollow"><code>invokespecial</code></a> handles calling the constructor itself (which is internally compiled to a <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.9" rel="nofollow"><code>void</code> method named <code>&lt;init&gt;</code></a>, hence the <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3" rel="nofollow">descriptor</a> <code>&lt;init&gt;()V</code>).</p> <p>Moving on, internals of object allocation and <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.7" rel="nofollow">representation on the heap are entirely JVM specific</a>. However, as far as I know, there is only <strong>one</strong> allocated object per allocated object, no matter its number of super classes. The object itself in memory has space for the instance fields of both its own class and its super classes. It must also have space for a <a href="http://en.wikipedia.org/wiki/Virtual_method_table" rel="nofollow"><em>virtual method table</em></a>, in order to do virtual dispatch when performing virtual method calls (e.g. via <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10.1.4.5.invokevirtual" rel="nofollow"><code>invokevirtual</code></a>) for the object.</p> <p>Internally, the Oracle HotSpot JVM manages things called <em>oops</em>, or ordinary object pointers. You can read more about the HotSpot memory layout <a href="https://wikis.oracle.com/display/HotSpotInternals/CompressedOops" rel="nofollow">here</a>. Feel free to <a href="http://hg.openjdk.java.net/jdk7/hotspot/hotspot/" rel="nofollow">browse the HotSpot source repository</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload