Reputation: 1814
I would like to know if when debugging in Eclipse, is there a feature/way to focus on a variable and "back-track" where the variable got its value..? I hope I'm being clear enough, but I can see if this appears as a weird question.
The thing is, I have two similar classes, both using a @Resource instance of the same class. One of the classes runs fine but the other one gets a NullPointerException for the instance variable in question. And I can't see how this is. So if you know a way to "back-track" in the Eclipse debugger to see "how old" and where a value in a variable is set I would greatly appreciate it!
And if there's no such feature for some obvious reason and this question in stupid I apologize in advance...
Upvotes: 3
Views: 2159
Reputation: 128939
You'd have to set a field breakpoint on the field in question before the value is set and catch it when it happens. "Standard" debuggers don't have the back-in-time feature. Omniscient debuggers do, though. These record every single action taken by a VM so that you can ask these kinds of questions at any point during execution. They're not widely used and have understandably high performance penalties. There are at least a couple of open source ones out there: TOD and ODB.
Upvotes: 2
Reputation: 2388
Unfortunately this is not possible in the standard Eclipse debugger. There is a commercial product called "Chronon Time-Travelling Debugger", which I have not tried but sounds as if it might do what you want, and is available for a 30-day free trial.
Upvotes: 2