aspose file tools*
The moose likes Java in General and the fly likes Slightly more subtle inheritance issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Slightly more subtle inheritance issue." Watch "Slightly more subtle inheritance issue." New topic
Author

Slightly more subtle inheritance issue.

Neil Mac
Greenhorn

Joined: Oct 03, 2003
Posts: 7
Hi,
If I have classes Sub2 which inherits from Sub1 which in turn inherits from Super1 and each class defines the instance method someMethod() (i.e. Sub1 and Sub2 override the method)...
How can I access the top level class definition of someMethod() from Sub2 ?
I can't use super.someMethod() as that will invoke the method defined in Sub1 and I can't cast the 'this' reference as that only casts the reference type and has no bearing on which method is executed.
I'm going to stick my neck out here and say that it can't be done...
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You are correct - you can't do that.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
new Super1().someMethod(); will work.
---------------
Sainudheen
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Spider Man:
Welcome to JavaRanch!
We don't have many rules here at JavaRanch, but we do have one. Please change your display name to comply with The JavaRanch Naming Policy. (We are looking for names that are not obviously fictitious...)
Thanks Pardner! Hope to see you around the Ranch!


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Slightly more subtle inheritance issue.