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.
Difference between revisions of "OT Bytecode Attributes/OTSpecialAccess"
(New page: =Attribute OTSpecialAccess= ===Intent=== This attribute combines information about several situations where accessing one element across classes requires special treatment: * '''decapsula...) |
|||
Line 3: | Line 3: | ||
===Intent=== | ===Intent=== | ||
This attribute combines information about several situations where accessing one element across classes requires special treatment: | This attribute combines information about several situations where accessing one element across classes requires special treatment: | ||
− | * '''decapsulation''' (base method accessed by role) => OTRE | + | * '''method-decapsulation''' (inaccessible base method accessed by role) => OTRE provides accessor method |
− | * ''' | + | * '''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 | ||
* '''base-class access''' -- two situations | * '''base-class access''' -- two situations | ||
+ | :* all base classes that are affected by method- or field-decapsulation | ||
:* base-class decapsulation (role accesses invisible base-class) => OTRE removes protection | :* base-class decapsulation (role accesses invisible base-class) => OTRE removes protection | ||
− | |||
===Location:=== | ===Location:=== | ||
− | + | Team class containing one or more roles requesting decapsulation. | |
===Content:=== | ===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:=== | ===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. | ||
+ | Base class decapsulation is supported by changing the access flags of the base class. | ||
===Format:=== | ===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: | + | The items of the '''OTSpecialAccess''' structure are as follows: |
*attribute_name_index | *attribute_name_index | ||
− | :The constant_pool entry at that index must be a CONSTANT_Utf8_info representing the string " | + | :The constant_pool entry at that index must be a CONSTANT_Utf8_info representing the string "OTSpecialAccess". |
*attribute_length | *attribute_length | ||
:The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes. | :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 <tt>declaringClass!selector</tt> (for static methods) or <tt>declaringClass?selector</tt> (for instance methods). Here <tt>declaringClass</tt> 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 | ||
+ | |||
[[Category:Object Teams Development]] | [[Category:Object Teams Development]] |
Revision as of 13:38, 3 July 2010
Attribute OTSpecialAccess
Intent
This attribute combines information about several situations where accessing one element across classes requires special treatment:
- method-decapsulation (inaccessible base method accessed by role) => OTRE provides accessor method
- 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
- base-class access -- two situations
- all base classes that are affected by method- or field-decapsulation
- base-class decapsulation (role accesses invisible base-class) => OTRE removes protection
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. Base class decapsulation is supported by changing the access flags of the base class.
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