Implementing a standalone super option that violates the sending of a virtual method would be an extremely bad idea.
Think about it for a while.
abstract class Base { abstract String Description(); String toString() { return "Base"; } } class Derived extends Base { String Description() { return "Derived description"; } String toString() { return "Derived"; } static void use(Base instance) { System.out.println(instance.toString()); System.out.println(instance.Description()); } }
Now let's take your suggestion and suppose that super really does what you offer; then we can write in Derived :
class Derived extends Base {
Now, if I understand you, you assume that the main function should print in order:
- implementation of
toString() from Derived : Derived . - implementation of
Description() from Derived : "Derived description" - implementation of
toString() from Base : "Base". - implementation of
Description() from Base : it does not exist. And two solutions that I can come up with lead to big problems:- Raise the exception: congratulations, now you can break any program that relies on abstract methods that are actually implemented without even thinking about it. (How did you know that the function will call the abstract method?)
- Return implementation from
Derived : negotiate sequence.
In short, this use of the word super conceptually violates object-oriented programming.
source share