Sorry, no, there is not a simple programmatic way to determine which variable or method call is the source of the exception. You could use something like Aspect-Oriented Programming (AOP), e.g. AspectJ, but this is not inherent to the language and is not generally incorporated into a program simply for debugging purposes.
if (var==null) -> too much work
try { } catch() { }
Debugger
I know you don't want to hear this, but these are simply the cost of doing business.
if (this.superSL.items.get(name).getSource().compareTo(VIsualShoppingList.Source_EXTRA)==0) {
It is unusual to see so many strung together method calls. I believe you best bet is to get in the habit of breaking these up more - not necessary down to 1 call per line, but fewer than this. Why?
1) Correctness
- is it valid in the design for one of these calls to return null? If so, you should break it out, test it, and handle it appropriately.
2) Understandability
- it would be easier for future maintainers (including future you) to understand if you intermediate, well-named variables to help clarify what is happening on this line.
3) Efficiency
- usually when you go so deep into a graph (stringing together a series of method calls), its likely you will need to go back down around there later. Capturing this intermediate value in an intermediate variable means avoiding making one or more method calls again.
4) Debugging
- as indicating by your question, spltiting a complex line like this up simplifies debugging. by narrowing down the possible source of the exception.