Ticket #158 (closed enhancement: fixed)

Opened 23 months ago

Last modified 22 months ago

support calling the super version of a bound base method

Reported by: stephan Owned by: stephan
Priority: major Milestone: OTDT_1.2.4
Component: compiler Version: 1.2.3
Keywords: Cc: mosconi@…

Description (last modified by stephan) (diff)

When adapting a base method by copying its code into a callin method, any contained super call will no longer work, because it is now out off context.

Therefor it would be desirable to support a special kind of base call

base.super.m();

that has exactly the same semantics as the original super call had. Such a call would have to be bound statically to the same method that that original super call was bound to (i.e., from the bound base class's super class). Also, no callin bindings would apply to such base-super call.

Such calls should be used with care, because they kind-of break the contract of the bound base class, which normally fully hides the overridden super method. Thus, we should consider flagging this as a form of decapsulation.

Change History

Changed 23 months ago by stephan

  • description modified (diff)

Changed 23 months ago by stephan

  • status changed from new to accepted

Initial implementation in r19143 & r19144.

Regressions are fixed in r19147, r19148, r19149, r19150.

A new paragraph OTJLD §4.3(f) has been drafted in r19153.

Implementation involves two stages:

  • the base call surrogate receives an additional boolean argument ('isSuperAccess') to discriminate regular base calls from base super calls.
  • an access method _OT$bm$super is generated into the baseclass which only contains an invokespecial to the super method (actually a "wicked super call"). The need to create this access method is announced by a new kind in OTSpecialAccessAttribute.

Whether or not this strategy is applied during weaving depends on the compiler version by which a given class file was generated (new strategy only for version >= 1.2.4).

Not yet implemented: error reporting (e.g., base super method does not exist) and decapsulation warning.

OTJLD needs to be updated regarding: (1) a new syntax rule (2) documentation of changes between versions.

A current snapshot is uploaded to http://www.objectteams.org/distrib/otdt-updates-1.2-4.3.f. Note, that due to changes in the bytecode format, an update from older 1.2.4-snapshots to this version is not possible (code compiled by a 1.2.4 compiler is assumed to have the new format).

Changed 23 months ago by stephan

  • status changed from accepted to closed
  • resolution set to fixed

Remaining issues have been settled:

Changed 22 months ago by stephan

Just for documentation, these are the tests for the new feature:

Note: See TracTickets for help on using tickets.