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

字节码在上面,为什么左边的数字是0 1 3 4 5 7 ...,而不是连续的,例如0 1 2 3 4 5 6 7 ...,缺少2和6是否意味着什么?

4

1 回答 1

4

它不是一个序列,而是偏移量。因此取决于操作的物理大小(以字节为单位),例如 2、3、4 字节长度,然后下一个将从该偏移量开始。例如,newarray int似乎占用 2 个字节,这就是为什么dup从 3 开始,依此类推。

这是一些文章,解释输出格式

在此处输入图像描述

于 2018-10-29T12:32:07.140 回答