Is there any way to forbid the son class to call the public method of super class in java?
For example
public abstract class TObject{
abstract public void quark();
}
public class Animal extends TObject{
public void quark(){
System.out.println("this is the animal");
}
}
public class Dog extends Animal{
@overide
public void quark(){
System.out.println("this is the animal");
**super.quark();**
}
}
In this example, The Dog call the **super.quark();** in it's quark method.
But I don't want the Dog could call super.quark(); and I also don't want to change the
modifier of quark method in Animal to private. Is there any way to prevent this in compile?
I have be confused couple of days, who can help me........
The reason I do that is I met the similar problem in developing hudson scm plugin.I
created the class which extends the SubversionSCM(the offical class). I just wanted to
override the public method of super class, then call super's public method back like
example. but the compile gave error.I don't konw why, how could it do? Dose java have
something like *reflect way*s to prevent this?