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


7.2 Class Attributes

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

Each of these attributes, except when stated otherwise, can occur in a class file many times. In case an attribute can occur only once, but actually occurs more than once, the class file should be treated as malformed and should not be further processed.

7.2.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.2.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:

7.2.3 GhostField Attribute

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

     GhostField_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 fields_count;
       {
         u2 access_flags;
         u4 BML_flags;
         u2 name_index;
         u2 descriptor_index;
       } fields[fields_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). [JCh 20080312: do we allow more than one GhostField attribute? The same question is valid for: GhostField, ModelField, ModelMethod. BTW: Shouldn't they be given a plural name (e.g. GhostFields) ?]

7.2.4 ModelField Attribute

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

     ModelField_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 fields_count;
       {
         u2 access_flags;
         u4 BML_flags;
         u2 name_index;
         u2 descriptor_index;
       } fields[fields_count];
     }

The meaning of the fields:

Represents clauses for model fields are stored in RepresentsClause Attributes, see Class Attributes.

7.2.5 ModelMethod Attribute

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

     ModelMethod_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.2.6 ClassInvariant Attribute

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

     ClassInvariant_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 access_flags;
       formula_info invariant;
     }

The meaning of the fields is as follows:

7.2.7 Constraint Attribute

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

     Constraint_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 access_flags;
       formula_info constraint;
     }

The meaning of the fields is as follows:

7.2.8 InitiallyClause Attribute

This atribute represents an “initially” clause of a class. It is a condition that is supposed to hold right after the creation of the object, i.e. after the termination of any of it constructors. It has the following structure:

     InitiallyClause_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 access_flags;
       formula_info clause;
     }

The meaning of the fields is as follows:

7.2.9 RepresentsClause Attribute

This atribute describes a “represents” clause, saying what is the meaning of a particular model field. It has the following structure:

     RepresentsClause_attribute {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 access_flags;
       expression_info field;
       expression_info spec;
     }

The meaning of the fields is as follows:

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

7.2.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 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 cp_count, then all references #n with n smaller than cp_count are references to the JVM constant pool, and references #n with n greater or equal than cp_count are references to a field in the second constant pool with index n-cp_count. References #n with n greater or equal to cp_count+second_cp_count are invalid. This attribute can occur only once.

7.2.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 extensions of BML, more advanced specification constructs, e.g., model classes, might require the use of class modifiers. Therefore, the attribute is defined anyway.