private List<Diagnostic<? extends JavaFileObject>> doCompile() {
    List<VolatileJavaFile> sources = packager.getEmitter().getEmitted();
    if (dump) {
      for (JavaFileObject java : sources) {
        try {
          System.out.println("====" + java.getName());
          System.out.println(java.getCharContent(true));
        } catch (IOException e) {
          // ignore.
        }
      }
    }

    for (JavaFileObject java : sources) {
      javaCompiler.addSource(java);
    }
    if (sources.isEmpty()) {
      javaCompiler.addSource(new VolatileJavaFile("A", "public class A {}"));
    }
    List<Diagnostic<? extends JavaFileObject>> diagnostics = javaCompiler.doCompile();
    if (dump) {
      for (Diagnostic<? extends JavaFileObject> d : diagnostics) {
        System.out.println("====");
        System.out.println(d);
      }
    }
    return diagnostics;
  }
 /**
  * エミッターに追加された結果を元にコンパイルを実行する。
  *
  * @return 結果をロードするためのローダー
  */
 protected ClassLoader start() {
   List<Diagnostic<? extends JavaFileObject>> diagnostics = doCompile();
   for (Diagnostic<?> d : diagnostics) {
     if (d.getKind() != Diagnostic.Kind.NOTE) {
       throw new AssertionError(diagnostics);
     }
   }
   return javaCompiler.getClassLoader();
 }
 /**
  * Cleans up the test.
  *
  * @throws Exception if some errors were occurred
  */
 @After
 public void tearDown() throws Exception {
   javaCompiler.close();
 }