[otj-users] Overriding callins
Michael Krüger
Michael.Krueger at first.fraunhofer.de
Mon Nov 21 18:36:45 CET 2005
Hello,
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?
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.
--- 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()
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?
Appendix:
§4.1 (e) Named callin binding
Any callin binding may be labeled with a name. The name of a callin
binding is used for declaring precedence (§ 4.8). A named callin binding
overrides any inherited callin binding (explicit and implicit (§ 1.3.1))
with the same name.
Thanks,
Michael
More information about the otj-users
mailing list