OT Bytecode Attributes/AnchorUsageRanks

From Eclipsepedia

Jump to: navigation, search

Contents

Attribute AnchorUsageRanks

Intent

The AnchorUsageRanks attribute is a variable-length attribute used in the attributes table of field_info structures. This attribute stores interdependencies between value and type parameters.

Location:

A field representing a value parameter OTJLD §9.1.a.

Content:

A list of ranks of type parameters that are anchored to the given value parameter (see OTJLD §9.2.1.a).

Purpose:

(not used by the OTRE)

Consider, e.g., a generic class

  class MyClass<MyTeam t, U, R1<@t>, R2<@t>> { /* body omitted */ }

From this a final field t is generated to which this attribute is attached. The attribute value is a list of ranks (zero-based, here {1,2}) referring to the second and third type parameter (not counting the value parameter t), saying that those parameters R1 and R2 are anchored to the field t.

Format:

   AnchorUsageRanks {
     u2 attribute_name_index;
     u4 attribute_length;
     u2 rank_count;
     u2 ranks[rank_count];
    } 

The items of the AnchorUsageRanks structure are as follows:

  • attribute_name_index
The constant_pool entry at that index must be a CONSTANT_Utf8_info representing the string "AnchorUsageRanks".
  • attribute_length
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.
  • rank_count
The number of rank values
  • ranks[]
Each value is a zero-based index into the list of type parameters (not counting value parameters), stating that the referenced type parameter is anchored to the current field.