title: "Uncompilable source code" RuntimeException in netbeans
body: <p>I'm trying to help another developer who is using Netbeans. When he runs or debugs some code of his in Netbeans (6.9.1) he gets an "Uncompilable source code" <code>RuntimeException</code>. I'm pretty experienced in Java but am more used to IntelliJ, and haven't used Netbeans at all. </p>
  
  <p>I've done it a bit of googling and it seems Netbeans will compile code even with errors, and then throw the <code>RuntimeException</code> at the errors. (Fairly bad behaviour IMO, but I guess some will find it useful.) I've got him to completely rebuild the project with no compile errors, but the <code>RuntimeException</code> seems to still occur. I assume he's got some bad cached class data somewhere deep within Netbeans.</p>
  
  <p>2 questions:</p>
  
  <ol>
  <li>What is the best way to clear the cache so we can find out where the uncompilable code is?</li>
  <li>Is there any way of turning off this behaviour so the code won't run/debug unless everything will compile, so these RuntimeException's won't be injected into the code?</li>
  </ol>
  
  <p>I've googled a fair bit, but haven't found the answer to either of these questions yet.</p>
  
  <hr>
  
  <p>Update: More information: </p>
  
  <ol>
  <li>Turning off the "compile on save" option makes the problem go away. Turning CoS back on again brings the exception back. Unfortunately this isn't a fix, as CoS is a very useful option.</li>
  <li><a href="http://netbeans.org/bugzilla/show_bug.cgi?id=182009">http://netbeans.org/bugzilla/show_bug.cgi?id=182009</a> seems the closest bug report, but it has been closed as "RESOLVED INCOMPLETE". Unfortunately the bug is hard to reproduce - the exception is happening in Java library code, when it calls a third-party library, so there isn't anything at the point the exception is thrown we can change. And the code will work for weeks, and then suddenly start throwing this error with no obvious reason why.</li>
  <li>We've tried manually deleting the entire build directory - still not a fix.</li>
  </ol>