title: Test if java-code does NOT compile
body: <p>It might sound a little bit weird, but I am looking for a possibility to test if some statements in the code are <strong>rejected</strong> by the typechecker (which means that the code should <strong>NOT</strong> compile).</p>
  
  <p>Be explain my intend: I am running a controlled experiment on type-systems where my subjects have to write some methods in java for me. The functionality of the methods written by the subjects can be easily tested using unit-tests, but I also want the methods to be well-typed (which means that some methodcalls should <strong>not</strong> be allowed).</p>
  
  <p>One way I could imagine to achieve that would be writing the statements which should break the build into a seperate file, add it to the classpath and run javac to see if any error occurs during the build. Although this might work, it does not feel very sophisticated, so my question is: <strong>Is there any better way to (automatically) test if some statements are refected by the typechecker?</strong></p>