harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy,Jing Lv" <firep...@gmail.com>
Subject Re: strong type cast needed in java. (overriding enhancement.)
Date Thu, 23 Dec 2010 10:04:51 GMT
Hi Hari,

      I see there is no such mechanism for Java now. I suppose it may be due
to java single inheritance and dynamic bonding.
     Technically strong type casting is possible with bytecode instruction
or something, however I'd rather design it clear to avoid such invoking -
say, if you want A.foo(), create A a = new A(), or avoid overriding foo() in
B. It sounds a syntax problem to invoke a parent method in a child class
instance while the method is already overrode.  It may have some problem
with strong type casting. For an example, if you have a public basic type A,
which has an implemented method foo(), and then create some internal
implementation B, C, which C extends B and both of them override foo(). With
a factory of A you can get an object "a" which is really C instances, then
it will be hard to tell what can be invoked for a.super.foo()?

     Sorry I don't catch you that what is the benefit do you think for
strong type casting on Java?

2010/12/23 hari ks <hari_tcs@yahoo.com>

> I have put up a post here :
> http://programparadigm.blogspot.com/2010/12/method-overriding-enhancements-strong.html
> Suppose class B extends A.
> A a = new B();
> ((A)a).foo(); // still calls class B's foo() method.
> Can something like "a.super.foo();" method invocation be made possible. Or
> ((A
> strong)a).foo();  should call A's foo() method with B's instance data.
> similar thing for C++.
> Is there a way to already do this?
> thanks & regards,
> Hari


Best Regards!

Jimmy, Jing Lv

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message