title: Eclipse ADT: Impossibly weird boolean behavior
body: <p>I'm having trouble changing variable values while at a breakpoint in debug mode. As a test, I have a simple loop with a boolean that gets toggled every pass:</p>
  
  <pre><code> booleanTest = !booleanTest;
  </code></pre>
  
  <p>Works great when I first start the program. Each time through the loop, the boolean toggles to its opposite state and Eclipse properly shows its value in the Variables window.</p>
  
  <p>So I decide to change its value in the Variables window. In this case, I caught it when it was true, so I switch it to false (the Variables window provides a dropdown menu with those two options so I know it recognizes it as a boolean). At that point, the variable STOPS TOGGLING. That is not a typo. It stays false every iteration of the loop, despite the code working perfectly during this same debug session.</p>
  
  <p>Here's the best part: If I manually select the "true" option in the Variables window, it flips back to true - and starts toggling properly again!</p>
  
  <p>The only thing I can imagine that would cause this behavior is if the Eclipse debugger's idea of what "false" means is different than the Eclipse compiler's idea. Normally false is zero, as in all bits are cleared. I don't know how Java implements the "!" operator (the docs say it "inverts the value of a boolean"), but if it is an XOR of all bits then the wrong "false" could invert to something not recognized as a "true". I admit this is a reach, but I'm at a loss to explain what I'm seeing.</p>
  
  <p>For kicks, I just tried this with a tertiary statement:</p>
  
  <pre><code> booleanTest = (booleanTest ? false : true);
  </code></pre>
  
  <p>...to see if a completely different approach makes a difference. It does not, the behavior is exactly the same. If I manually set booleanTest to true, the above code does not toggle it. Set it back to false and it toggles perfectly. This is during the same debug session, I don't even have to restart the app.</p>
  
  <p>I also noticed something else: When it's toggling properly, it requires TWO hits on the F6 (single step) key to execute the line when moving from false to true. The highlighted line blinks but does not move on the first hit. But when that particular iteration of the loop is switching booleanTest from true to false, only a single F6 is necessary - it immediately toggles and the highlighted line advances.</p>
  
  <p>Weirdest thing I've seen in a while. This is 100% reproducible. I've done it on my laptop and on my main machine.</p>
  
  <p>Anyone have any ideas? Thanks!</p>