[otj-users] Overriding callins
Christine Hundt
resix at cs.tu-berlin.de
Wed Nov 23 16:08:30 CET 2005
Hello Michael,
Michael Krüger wrote:
> I'm experimenting with inheriting and overriding callins.
> I understand, that the only way to override a callin is
> by redeclaring a callin with the same name, e.g. "c1".
> But does this currently (CVS) work?
thanks for your comments! The possibility to override callin bindings is
a relative new feature of ObjectTeams. At the moment it only works for
specific cases (see below)
> Problem #1
> Overriding in §4.1 (e) seems to be true only for
> bindings with the same name, same modifier, same role method and base
> method designator.
Execpt for the 'same role method designator' this observation is correct.
If you change the method binding in role R2 to
"c1: method2 <- before m1;" this will truly override the 'c1' binding of
the super role R1.
> --- Example 1 ----------------------------------------------------
> public team class TB
> {
> public class R0
> {
> public void method1() { System.out.println("method1()"); }
> public void method2() { System.out.println("method2()"); }
> }
>
> public class R1 extends R0 playedBy C1
> {
> c1: method1 <- before m1;
> }
>
> public class R2 extends R1
> {
> c1: method2 <- after m2;
> }
> }
> ------------------------------------------------------------------
> Calls to m1() and m2() prints both
> > method1() // just before m1()
> > method2() // just after m2()
>
The problem is, that in all cases, where the bound base method and/or
the binding modifier is changed, we will have to 'unweave' aspects from
a base method. If a binding to a base method is overriden by a binding
to another base method the old base method may no longer have a callin
at all. If only the binding modifier is changed, at least the old
position (after/before/replace) may no longer trigger a callin. Such an
unweaving is not done at the moment.
>
> Problem #2
> If the redeclared callin has the same name, modifier,
> role and base method designators, the overridden callin
> is still available with a certain precedence declaration.
>
> --- Example 2 --------------------------------------------------------
> public team class TB
> {
> //precedence R2, R1;
> //precedence R1, R2;
>
> public class R0
> {
> public void method1() { System.out.println("method1()"); }
> public void method2() { System.out.println("method2()"); }
> }
>
> public class R1 extends R0 playedBy C1
> {
> c1: method1 <- after m1;
> }
>
> public class R2 extends R1
> {
> c1: method1 <- after m1;
> }
> }
> ------------------------------------------------------------------
> Call to m1() prints one of the following
>
> without precedence
> > method1()
>
> with "precedence: R1, R2;"
> > method1()
>
> with "precedence: R2, R1;"
> > method1()
> > method1()
>
>
> Question: Is this the desired behavior, or is it broken?
This seems to be a bug. I will further analyze it.
Cheers,
Christine
More information about the otj-users
mailing list