Next: , Previous: Encoding of Expressions, Up: Encoding of BML in Class File Format

7.2 Combined Constant Pool

The constants referenced in BML-related attributes that are not defined in the constant pool (see Constant Pool) are stored in the second constant pool (see SecondConstantPool Attribute). The constants are referenced by numbers. Assume that we want to find the value of the constant at index n. There is a value associated with the Second Constant Pool which is the basis for the constant numbering. The basis is stored in the field first_cp_count of the attribute. If the number n is small enough (i.e. it is not greater than the basis) then it is an index in the first constant pool and if it is larger than the basis then it is a reference to the constant number (n - first_cp_count - 1) in the table which contains the entries of the second constant pool (assuming the indexing of the table starts with 0). Indexes which are interpretable in that way are called indexes in the Combined Constant Pool.

To avoid any ambiguity indexes in the JVM constant pool will be called indexes in the primary constant pool.

Note that in the textual representation of BML the actual names and variables may appear in formulas and expressions instead of references to items in the first or second constant pool. Therefore both ways of expressing names and variables should be supported by textual tools to edit and view BML annotations. In binary representation, only the references to constant pool are allowed.