I use "javap -verbose" to parse a class file and find the constant pool lost #3, anybody can tell me the reason?
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 theclass
file. If aCONSTANT_Long_info
orCONSTANT_Double_info
structure is the item in theconstant_pool
table at index n, then the next usable item in the pool is located at index n+2. Theconstant_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
”…
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.