tags:

views:

65

answers:

3

Hello!

I found something strange about an eclipse debugger. First of all, when a program runs as a simple Java Application, everything is ok, but when I use debugger some references become null so that I catch NullPointerException.

Here is much more strange example:

System.out.println("the list size is " + list.getSize());
System.out.println("the list size is " + list.getSize());
System.out.println("the list size is " + list.getSize());
System.out.println("the list size is " + list.getSize());

When I start a program the output is : 50, 50, 50, 50.

But when I use debugger the output is : 50, 49, 48, 47. That is REALLY strange, because getSize() method changes nothing. Could you please help me?

A: 

It's impossible if the list is created just before and with a single threaded application.

Manuel Selva
Possible if there in some custom code in "detail formatters", for instance
Nivas
Yes, I understand that it is really strange, but it is a fact =(
Dmitry
+1  A: 

Do you have any custom code in the debugger ("change value" in variables view accepts statements) that might change the list? Like list.remove() as a custom value for some variable?

Also check the "detail formatters" for the variables in the variables view, whether there is some code there for this list or some other variable.

Nivas
Thank you, I'll check
Dmitry
And what will you suggest abot NullPointerExceptions? Why could it be?
Dmitry
NullPointers are strange, unless you explicitly pause the debugger and "change value" of the variable to null. Is it possible that you have some "detail formatter" code that make this list null, as a side effect?
Nivas
May be, but I didn't change anything. Even didn't use this option...
Dmitry
Can you crosscheck, just to be sure?
Nivas
+1  A: 

Thank's everybody!!!

The problem was, as tulskiy said, I had a watch expression that changed the list.

Dmitry