Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

OT Bytecode Attributes/OTSpecialAccess

Attribute OTSpecialAccess

Intent

This attribute combines information about several situations where accessing one element across classes requires special treatment:

  • Access from a role requires generation of a synthetic access method
  • Accessing a baseclass itself requires changing its access modifiers.

Location:

Team class containing one or more roles requesting decapsulation.

Content:

Two consecutive lists:

  • a polymorphic list of decapsulation info for members (methods, fields, super-methods)
  • a list of base classes (some of this may be subject to decapsulation)

Purpose:

The OTRE uses this attribute to make accessible those elements that shall be accessed using decapsulation. This is done by generating access methods for all affected methods, fields and super-methods.

  • method-decapsulation (inaccessible base method accessed by role)
    • constructor: => OTRE changes access modifiers
    • method: => OTRE generates accessor method (differentiate static/instance methods)
  • field-decapsulation (inaccessible base field accessed by role)
=> OTRE adds setter/getter
  • super-method-access (a base method is accessed using a base.super call)
=> OTRE provides accessor method to invoke the target method using invokespecial
  • base-class access -- two situations
  • base-class decapsulation (role accesses invisible base-class)
=> OTRE removes protection
  • report super classes of directly bound base classes if super-method-access is applied
=> This information is used by OT/Equinox to ensure correct load order


Format:

 OTSpecialAccess {
       u2 attribute_name_index;
       u4 attribute_length;
       u2 member_decapsulation_count;
       MemberDecapsulation member_decapsulations[member_decapsulation_count];
       u2 baseclass_count;
       Baseclass baseclasses[baseclass_count];
 }
 union MemberDecapsulation {
       MethodDecapsulation methodDesc;
       FieldDecapsulation fieldDesc;
       SuperMethodAccess superMethodDesc;
 }
 MethodDecapsulation {
       u1 selector=1;
       u2 class_name_index;
       u2 encoded_method_selector_index;
       u2 signature_index;
 }
 FieldDecapsulation {
       u1 selector=2;
       u1 flags;
       u2 class_name_index;
       u2 field_name_index;
       u2 field_signature_index;
 }
 SuperMethodAccess {
       u1 selector=3;
       u2 class_name_index;
       u2 superclass_name_index;
       u2 method_selector_index;
       u2 signature_index;
 }
 Baseclass {
       u2 baseclass_name_index;
       u1 is_decapsulation;
 }

The items of the OTSpecialAccess structure are as follows:

  • attribute_name_index
The constant_pool entry at that index must be a CONSTANT_Utf8_info representing the string "OTSpecialAccess".
  • attribute_length
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.
  • member_decapsulation_count
Number of MemberDecapsulation entries
  • member_decapsulations
Array of entries describing decapsulation of one member. Each element is one of MethodDecapsulation, FieldDecapsulation or SuperMethodAccess.
  • baseclass_count
Number of entries for baseclasses
  • baseclasses
Array of base classes to which the current team binds roles.

The items of the MethodDecapsulation structure are as follows:

  • selector
Constant 1 to discriminate among alternatives of MemberDecapsulation
  • class_name_index
Constant pool index pointing to the name of the bound base class
  • encoded_method_selector_index
Constant pool index pointing to the name of the decapsulated method. For non-constructor methods this name is encoded either as declaringClass!selector (for static methods) or declaringClass?selector (for instance methods). Here declaringClass is the class actually declaring the method
  • signature_index
Constant pool index for the string-encoded signature of the method

The items of the FieldDecapsulation structure are as follows:

  • selector
Constant 2 to discriminate among alternatives of MemberDecapsulation
  • class_name_index
Constant pool index pointing to the name of the bound base class
  • field_name_index
Constant pool index pointing to the name of the decapsulated field.
  • signature_index
Constant pool index for the string-encoded signature (type) of the field

The items of the SuperMethodAccess structure are as follows:

  • selector
Constant 3 to discriminate among alternatives of MemberDecapsulation
  • class_name_index
Constant pool index pointing to the name of the declaring class for the method
  • superclass_name_index
Constant pool index pointing to the name of the superclass of the declaring class for the method
  • method_selector_index
Constant pool index pointing to the selector of the decapsulated method.
  • signature_index
Constant pool index for the string-encoded signature of the method

The items of the Baseclass structure are as follows:

  • baseclass_name_index
Constant pool index for the name of a bound baseclass
  • is_decapsulation
flag (0=false, 1=true) to signal whether decapsulation is applied to the baseclass itself

Back to the top