when debugging java code, in the stack trace, I noticed that something in the following
ToyotaCar(AbstractCar).handle()
line: 40
It looks like the class in the brace is the base class. Will eclipse always show the base class?
If you invoke a method of a base class, the stack line will show both the base class (where the method is defined) and the class of the object that invoked such method.
I assume here that you did something like
ToyotaCar car = new ToyotaCar();
car.handle();
where ToyotaCar
does not override the handle()
method. The stack trace notifies you that your call to handle()
is not served by the actual ToyotaCar
, but by AbstractCar
. Yet, you invoked it on a ToyotaCar
object.
By itself, this notation for a stack line might seem excessive if you don't override base class methods. Consider, however, the case where you want to override the handle()
method, but still need to call handle()
on AbstractCar
. You will need to issue a
super.handle();
inside ToyotaCar.handle()
. When calling the handle()
method on a ToyotaCar
object, you will first call it as a ToyotaCar
and then as an AbstractCar
. The two stack lines will unambiguously allow you to tell one call from the other.