title: Java entering an if statement that is false
body: <p>I'm running into the strangest error in this program, which is confirmed when debugging it. I have the following code (boiled down to highlight the problem, of course):</p>
  
  <h2><code>BHFrame.java</code></h2>
  
  <pre><code>public class BHFrame
  {
    private boolean uSS;
    private StateSaver stateSaver;
  
    public BHFrame(boolean useInternalStateSaver)
    {
      //Init code
  
      uSS = useInternalStateSaver;
  
      //More init code
      System.out.println(uSS);
      if (uSS)
      {System.out.println("Entered 1");
        stateSaver = new StateSaver(title, false);
        stateSaver.addSaveable(getThis());
      }
  
      //More init code
      System.out.println(uSS);
      if (uSS)
      {System.out.println("Entered 2");
        try
        {
          stateSaver.loadState();
          stateSaver.putState(getThis());
        }
        catch (IOException ex)
        {
          alertUserOfException(ex);
        }
      }
    }
  }
  </code></pre>
  
  <h2><code>GUI.java</code></h2>
  
  <pre><code>public class GUI extends BHFrame
  {
    public GUI(boolean useInternalStateSaver)
    {
      super(useInternalStateSaver);
    }
  }
  </code></pre>
  
  <h2><code>Main.java</code></h2>
  
  <pre><code>public class Main
  {
    public static void main(String[] args)
    {
      GUI gui = new GUI(false);
    }
  }
  </code></pre>
  
  <h2>Output</h2>
  
  <pre><code>false
  false
  Entered 2
  Exception in thread "main" java.lang.NullPointerException
      at bht.tools.comps.BHFrame.&lt;init&gt;(BHFrame.java:26)
      at bhms.GUI.&lt;init&gt;(GUI.java:5)
      at bhms.Main.main(Main.java:5)
  </code></pre>
  
  <p>The class <code>BHFrame</code> is extended and run from a child class that calls this constructor, but that really shouldn't affect this behavior. The problem is that, when <code>false</code> is passed to the constructor as <code>useInternalStateSaver</code>, the first <code>if (uSS)</code> is skipped, but the second is entered. Upon debugging, I found that <code>uSS</code> is <code>false</code> throughout runtime, including on the line of the second <code>if</code> statement, here. <strong>Why would Java enter an <code>if</code> statement when the condition returns <code>false</code>?</strong> Before you ask, I did delete the <code>.class</code> files and recompile it just in case there was some residual code messing with it, but I got the same result. And rest assured, all the references to the <code>uSS</code> variable are displayed here.</p>
  
  <h2>Solution</h2>
  
  <hr>
  
  <p>As it turns out, this appears to be a bug in NetBeans 7.1 Build 201109252201, wherein the IDE doesn't properly insert new code into the compiled <code>.class</code> files. The problem was fixed by compiling the files externally. A <a href="https://netbeans.org/bugzilla/show_bug.cgi?id=204605" rel="nofollow">bug report</a> has been submitted.</p>