Breakpoint changes behavior of program?! [message #259516] |
Fri, 10 April 2009 01:47 |
Eclipse User |
|
|
|
Originally posted by: m.junk.com
I am flummoxed. When I set a breakpoint and step through my code, a
variable unexpectedly and incorrectly changes. When I take out the
breakpoint, the variable correctly stays the same.
Line 1: MyClass myObject = new MyClass();
Line 2: System.out.println( myObject.variable );
myObject.variable is a boolean. It is not initialized to anything so it
is false. When I step through the MyClass() constructor, I see that
variable is false, which is correct. Once Line 1 is complete, variable is
false. HOWEVER, once I get to Line 2, variable becomes true! I cannot
for the life of me figure out why variable changes to true.
Furthermore, if I remove all breakpoints, the System.out.println prints
false. So the variable correctly stays false with no breakpoints, but
incorrectly becomes true with breakpoints. Has anyone else observed the
eclipse debugger causing their program to act strangely? Thanks in
advance.
|
|
|
Re: Breakpoint changes behavior of program?! [message #259519 is a reply to message #259516] |
Fri, 10 April 2009 05:39 |
Walter Harley Messages: 847 Registered: July 2009 |
Senior Member |
|
|
"New User" <m@junk.com> wrote in message
news:84465aa0472df723037eb5199ab873a8$1@www.eclipse.org...
>I am flummoxed. When I set a breakpoint and step through my code, a
>variable unexpectedly and incorrectly changes. When I take out the
>breakpoint, the variable correctly stays the same.
>
> Line 1: MyClass myObject = new MyClass();
> Line 2: System.out.println( myObject.variable );
>
> myObject.variable is a boolean. It is not initialized to anything so it
> is false. When I step through the MyClass() constructor, I see that
> variable is false, which is correct. Once Line 1 is complete, variable is
> false. HOWEVER, once I get to Line 2, variable becomes true! I cannot
> for the life of me figure out why variable changes to true.
>
> Furthermore, if I remove all breakpoints, the System.out.println prints
> false. So the variable correctly stays false with no breakpoints, but
> incorrectly becomes true with breakpoints. Has anyone else observed the
> eclipse debugger causing their program to act strangely? Thanks in
> advance.
Somehow I doubt the actual example is quite so simple :-) Are you working
with technologies such as AOJ, Spring, Hibernate, Terracotta etc. that can
change the actual identity of an object on the fly? Is this in the context
of multithreaded code?
Do you have any conditions associated with the breakpoint? (Are you sure?
Have you tried clearing all breakpoints?) I believe it's possible for
breakpoint conditions to have side effects, though I don't know for sure.
I haven't ever seen Eclipse change the state of a variable. I have seen it
fail to update in a timely way, particularly for long strings. Is it
possible the state of the variable is actually getting changed even sooner
than you think but the debugger hasn't refreshed?
Are you able to produce a small example that reproducibly demonstrates the
problem? If not, are you able to whittle down your code in the direction of
the small example, until the problem disappears?
|
|
|
Re: Breakpoint changes behavior of program?! [message #259527 is a reply to message #259519] |
Sat, 11 April 2009 01:45 |
Eclipse User |
|
|
|
Originally posted by: m.junk.com
I am happy to report that creating a new Eclipse workspace fixed the
problem.
Btw, unfortunately the problem was pretty much that simple. Also btw, I
found that I could do some things that might make it work, such as
starting my program outside of eclipse and attaching the debugger. But
making a new workspace fixed the problem 100%.
|
|
|
Re: Breakpoint changes behavior of program?! [message #259531 is a reply to message #259527] |
Sat, 11 April 2009 21:41 |
Walter Harley Messages: 847 Registered: July 2009 |
Senior Member |
|
|
"New User" <m@junk.com> wrote in message
news:a93c0e4da0aa97a65dda5c1d4aeb2834$1@www.eclipse.org...
>I am happy to report that creating a new Eclipse workspace fixed the
>problem.
>
> Btw, unfortunately the problem was pretty much that simple. Also btw, I
> found that I could do some things that might make it work, such as
> starting my program outside of eclipse and attaching the debugger. But
> making a new workspace fixed the problem 100%.
If you've still got the old workspace, or if you are able to reproduce the
problem, you could make a zip file of the entire workspace, including all
the .settings directories and so forth, and file a bug report in Bugzilla.
(As always, be sure to search Bugzilla first, to make sure you're not filing
a duplicate bug.)
|
|
|
Powered by
FUDForum. Page generated in 0.03871 seconds