title: java8 -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=16
body: <p>So, I'm trying to run some simple code, jdk-8, output via jol</p>
  
  <pre><code>    System.out.println(VMSupport.vmDetails());
      Integer i = new Integer(23);
      System.out.println(ClassLayout.parseInstance(i)
              .toPrintable());
  </code></pre>
  
  <p><strong>The first attempt is to run it with compressed oops disabled and compressed klass also on 64-bit JVM.</strong></p>
  
  <pre><code>-XX:-UseCompressedOops -XX:-UseCompressedClassPointers
  </code></pre>
  
  <p>The output, pretty much expected is :</p>
  
  <pre><code>Running 64-bit HotSpot VM.
  Objects are 8 bytes aligned.
  
  java.lang.Integer object internals:
  OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
    0     4       (object header)                01 00 00 00 (00000001 00000000 00000000 00000000) (1)
    4     4       (object header)                00 00 00 00 (00000000 00000000 00000000 00000000) (0)
    8     4       (object header)                48 33 36 97 (01001000 00110011 00110110 10010111) (-1758055608)
   12     4       (object header)                01 00 00 00 (00000001 00000000 00000000 00000000) (1)
   16     4   int Integer.value                  23
   20     4       (loss due to the next object alignment)
  
  Instance size: 24 bytes (reported by Instrumentation API)
  Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
  </code></pre>
  
  <p>That makes sense : 8 bytes klass word + 8 bytes mark word + 4 bytes for the actual value and 4 for padding (to align on 8 bytes) = 24 bytes.</p>
  
  <p><strong>The second attempt it to run it with compressed oops enabled compressed klass also on 64-bit JVM.</strong></p>
  
  <p>Again, the output is pretty much understandable :</p>
  
  <pre><code>Running 64-bit HotSpot VM.
  Using compressed oop with 3-bit shift.
  Using compressed klass with 3-bit shift.
  Objects are 8 bytes aligned.
  
  OFFSET  SIZE  TYPE DESCRIPTION                    VALUE
    0     4       (object header)                01 00 00 00 (00000001 00000000 00000000 00000000) (1)
    4     4       (object header)                00 00 00 00 (00000000 00000000 00000000 00000000) (0)
    8     4       (object header)                f9 33 01 f8 (11111001 00110011 00000001 11111000) (-134138887)
   12     4   int Dummy.i                        42
   Instance size: 16 bytes (reported by Instrumentation API).
  </code></pre>
  
  <p>4 bytes compressed oop (klass word) + 8 bytes mark word + 4 bytes for the value + no space loss = 16 bytes.</p>
  
  <p><strong>The thing that does NOT make sense to me is this use-case:</strong></p>
  
  <pre><code> -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:ObjectAlignmentInBytes=16
  </code></pre>
  
  <p>The output is this:</p>
  
  <pre><code> Running 64-bit HotSpot VM.
   Using compressed oop with 4-bit shift.
   Using compressed klass with 0x0000001000000000 base address and 0-bit shift.
  </code></pre>
  
  <p>I was really expecting to both be "4-bit shift". Why they are not?</p>
  
  <p><strong>EDIT</strong>
  The second example is run with :</p>
  
  <pre><code> XX:+UseCompressedOops -XX:+UseCompressedClassPointers
  </code></pre>
  
  <p>And the third one with :</p>
  
  <pre><code> -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:ObjectAlignmentInBytes=16
  </code></pre>