4.3.常量池(constant pool)

常量池是一个基于数组的多个条项,这些条项代表被所有方法使用的常量。每个计数项(如int_count)都要比对应数组内项的数目多1,因为数组的第1项是元素1。对所有的常量池,索引0都特殊含义,通常是明确的缺省值。比如,索引0可能根据不同的上下文代表空字符串"",任意名称空间,任意类型*0何时有特殊含义,将在下文指出。

cpool_info 
{ 
    u30 int_count 
    s32 integer[int_count] 
    u30 uint_count 
    u32 uinteger[uint_count] 
    u30 double_count 
    d64 double[double_count] 
    u30 string_count 
    string_info string[string_count] 
    u30 namespace_count 
    namespace_info namespace[namespace_count] 
    u30 ns_set_count 
    ns_set_info ns_set[ns_set_count] 
    u30 multiname_count 
    multiname_info multiname[multiname_count] 
} 

如果这些数组中对同一实体有多个项,比如名称,AVM可能也可能不认为这两项是相同的。目前AVM保证被标记为属于私有名称空间的名称才被认为是唯一的。

int_count, integer
int_countinteger数组中项的数目,再加1。integer数组保存字节码引用的正数常量。integer数组的第0项不存在于abcFile中,它代表零值,用于为可选参数和字段初始化赋值。

uint_count, uinteger