2
 static void heapVar();
Code:
   0: iconst_3
   1: newarray       int
   3: dup
   4: iconst_0
   5: bipush        100
   7: iastore
   8: dup
   9: iconst_1
  10: sipush        200
  13: iastore
  14: dup
  15: iconst_2
  16: sipush        300
  19: iastore
  20: astore_0
  21: return

Bytecodes are above, why the numbers on the left are 0 1 3 4 5 7 ..., not continous, like 0 1 2 3 4 5 6 7... , Does the missing of 2 and 6 mean something ?

cox
  • 466
  • 4
  • 8
  • The are *byte* offsets and the instructions have different sizes (see [here](https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-6.html) and [there](https://stackoverflow.com/q/38032729/2711488)). – Holger Oct 29 '18 at 18:45

1 Answers1

4

It is not a sequence, but offset. So depends on the physical size of operation in bytes, like 2, 3, 4 bytes length, then the next one will start with that offset. For instance, newarray int seems to occupy 2 bytes, that is why dup starts at 3, so on.

Here is some article, explaining output format.

enter image description here

muradm
  • 1,973
  • 19
  • 30