Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why super.super is not allowed?

19 views
Skip to first unread message

bea...@gmail.com

unread,
Apr 5, 2008, 1:42:10 PM4/5/08
to
Can anybody tell me why code like :
super.super.someMethod();
is not allowed?

thanks very much

Arne Vajhøj

unread,
Apr 5, 2008, 1:57:03 PM4/5/08
to
bea...@gmail.com wrote:
> Can anybody tell me why code like :
> super.super.someMethod();
> is not allowed?

It does not look like a feature that will be widely used, so
there may not be a specific reason other than "not enough reason
to add a feature".

Arne

Mark Thornton

unread,
Apr 5, 2008, 2:17:56 PM4/5/08
to

If the parent class has overidden a method why should you be permitted
to bypass that decision? Doing so may break the parent class.

Mark Thornton

CK

unread,
Apr 5, 2008, 2:16:43 PM4/5/08
to
Words to the wise, "bea...@gmail.com" <bea...@gmail.com> wrote:

>Can anybody tell me why code like :
>super.super.someMethod();
>is not allowed?

There normally is a reason for a class overwriting a method. If you
allow super.super.do(), then basically the hierarchical system of
inheritance is gone and you can have all classes defined as subclasses
of Object. Saying it this way might be a bit overkill, but I think
that is the general idea behind it.
--
Claus Dragon <clau...@mpsahotmail.com>
=(UDIC)=
d++ e++ T--
K1!2!3!456!7!S a29
"Coffee is a mocker. So, I am going to mock."

- Me, lately.

Andrea Francia

unread,
Apr 5, 2008, 2:42:50 PM4/5/08
to
bea...@gmail.com wrote:
> Can anybody tell me why code like :
> super.super.someMethod();
> is not allowed?

If a such feature would exists it should be avoided because it will
create an highly coupling between the class and its super super class.

--
Andrea Francia
http://www.andreafrancia.it/

Roedy Green

unread,
Apr 5, 2008, 4:43:03 PM4/5/08
to
On Sat, 5 Apr 2008 10:42:10 -0700 (PDT), "bea...@gmail.com"
<bea...@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>Can anybody tell me why code like :
>super.super.someMethod();
>is not allowed?

Because when you write a class you expose only as much as you need to.
If you don't expose something, there may well be good reason. Fiddling
with it could cause something in the parent class to stop working.
super.super would give you power to override those decisions.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Chase Preuninger

unread,
Apr 5, 2008, 9:06:04 PM4/5/08
to
Just doesnt work, however you may be able to do this using reflection
(to me it seems as if anything can be acomplished with reflection)

Patricia Shanahan

unread,
Apr 5, 2008, 9:11:56 PM4/5/08
to
Chase Preuninger wrote:
> Just doesnt work, however you may be able to do this using reflection
> (to me it seems as if anything can be acomplished with reflection)

I would be interested in seeing how you would do it. The problem is:

"If the underlying method is an instance method, it is invoked using
dynamic method lookup as documented in The Java Language Specification,
Second Edition, section 15.12.4.4; in particular, overriding based on
the runtime type of the target object will occur."

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html

Patricia

0 new messages