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


7.4 Class Attributes

The class attributes represent additional BML-entities added to a class

Each of these attributes is stored in the array of class atributes mentioned at the beginning of The Class File Format.

Each of the attributes may occur in a class file only once. However, if this is not specifically said for a given attribute, BML tools may read class files with multiple occurences of some attributes. In this case, all attributes of a given kind should be treated as sum of particular attributes. If it is explicitely said, that a given attributes can occur in a class file only once, in case it occurs more than once, the class file should be treated as malformed and should not be further processed.

7.4.1 Version Attribute

This attribute contains the version number of the BML specification annotations. The format of the attribute is as follows:

     Version_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 major;
       u2 minor;
     }

The meaning of the fields:

A major version number change indicates an incompatible change in the format of attributes. A minor version number change indicates a backward-compatible change, e.g., the addition of a new attribute or a new flag. This attribute can occur only once.

7.4.2 ClassModifiers Attribute

This attribute represents BML class modifiers. The format of the attribute is as follows:

     ClassModifiers_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u4 BML_flags;
     }

The meaning of the fields:

This attribute can occur only once.

7.4.3 GhostFields Attribute

This attribute contains information about a class's ghost fields. The format of the attribute is as follows:

     GhostFields_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 fields_count;
       field_info fields[fields_count];
     }

where field_info has the form as in Section 4.5 Fields of The Java Virtual Machine Specification [Lindholm-Yellin]:

     field_info {
       u2 access_flags;
       u2 name_index;
       u2 descriptor_index;
       u2 attributes_count;
       attribute_info attributes[attributes_count];
     }

The meaning of the fields:

The initial value of a ghost field must be set by a Set instruction in the static initializer (for static ghost fields) and constructors (for instance ghost fields).

7.4.4 ModelFields Attribute

This attribute contains information about a class's model fields. The format of the attribute is as follows:

     ModelFields_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 fields_count;
       field_info fields[fields_count];
     }

where field_info has the form as in Section 4.5 Fields of The Java Virtual Machine Specification [Lindholm-Yellin] and is presented in detail in GhostFields Attribute.

The meaning of the fields:

Represents clauses for model fields are stored in the RepresentsClauses Attribute.

7.4.5 ModelMethods Attribute

This attribute contains information about the model methods declared in the class. The format of the attribute is as follows:

     ModelMethods_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 methods_count;
       method_info methods[methods_count];
     }

The meaning of the fields is as follows:

Note that model methods that are part of an interface do not have to be static, like Java methods. This information is represented by the unset ACC_STATIC flag in the access_flags attribute of the method_info structure of the given method.

7.4.6 Invariants Attribute

This attribute describes the class invariants. It has the following structure:

     Invariants_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 invariants_count;
       {
         u2 access_flags;
         formula_info invariant;
       } invariants[invariants_count];
     }

The meaning of the fields is as follows:

7.4.7 Constraints Attribute

This attribute describes the history constraints of the class. It has the following structure:

     Constraints_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 constraints_count;
       {
         u2 access_flags;
         formula_info constraint;
       } constraints[constraints_count];
     }

The meaning of the fields is as follows:

7.4.8 InitiallyClauses Attribute

This attribute represents the “initially” clauses of a class. These are the conditions that are supposed to hold right after the creation of the class, i.e., after the termination of the static initializer (for static initially clauses), or after the creation of an object, i.e. after the termination of any of it constructors (for instance initially clauses). The attribute has the following structure:

     InitiallyClauses_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 clauses_count;
       {
         u2 access_flags;
         formula_info clause;
       } clauses[clauses_count];
     }

The meaning of the fields is as follows:

7.4.9 RepresentsClauses Attribute

This atribute describes the “represents” clauses of the class, saying what is the meaning of individual model fields. The attribute has the following structure:

     RepresentsClauses_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 clauses_count;
       {
         u2 access_flags;
         expression_info field;
         expression_info spec;
       } clauses[clauses_count];
     }

The meaning of the fields is as follows:

The field must be an expression referring to a model field defined in the class or its superclass.

7.4.10 SecondConstantPool Attribute

This attribute represents the second constant pool, containing all names and types that appear in the specification part of the class description. It has the following structure:

     SecondConstantPool_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 first_cp_count;
       u2 second_cp_count;
       cp_info second_cp[second_cp_count];
     }

The meaning of the fields is as follows:

The structure of this attribute closely resembles the definition of the JVM constant pool structure. If a JVM constant pool is of size first_cp_count, then all references #n with n not greater than first_cp_count are references to the JVM constant pool, and references #n with n greater than cp_count are references to a field in the second constant pool with index n-first_cp_count-1. References #n with n greater or equal to first_cp_count+second_cp_count+1 are invalid. This attribute can occur only once.

The reason to introduce first_cp_count is that other tools may add new constants to the Java constant pool and each such operation would destroy the consistency of indices to the Second Constant Pool in case there is no basis from which the count of indicies starts.

7.4.11 DataGroups Attribute

This attribute contains information abous static (non-trivial) data groups defined in the class. The format of the attribute is as follows:

     DataGroups_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 groups_count;
       {
          u2 name_index;
          u2 access_flags;
          assignable_info members;
       } groups[groups_count];
     }

The meaning of the fields:


Footnotes

[1] As mentioned above, in future versions of BML, more advanced specification constructs, e.g., model classes, might require the use of class modifiers. Therefore, the attribute is defined anyway.