0

I use "javap -verbose" to parse a class file and find the constant pool lost #3, anybody can tell me the reason?

enter image description here 

  

Mark Hall
  • 53,938
  • 9
  • 94
  • 111
maomao
  • 61
  • 2
  • 2
  • 6

2 Answers2

2

Note that the preceding entry has the type Long and its documentation says:

All 8-byte constants take up two entries in the constant_pool table of the class file. If a CONSTANT_Long_info or CONSTANT_Double_info structure is the item in the constant_pool table at index n, then the next usable item in the pool is located at index n+2. The constant_pool index n+1 must be valid but is considered unusable.

and the neat addition

In retrospect, making 8-byte constants take two constant pool entries was a poor choice.

So javap decided to simply skip the unusable entry instead of printing something like “#3 unusable”…

Holger
  • 285,553
  • 42
  • 434
  • 765
0

Longs and Doubles take up two slots in the constant pool, so the slot after them is skipped. In this case slot 2 holds a Long, so slot 3 is skipped.

Antimony
  • 37,781
  • 10
  • 100
  • 107