示例#1
0
  void run() throws Exception {
    File classesDir = new File("classes");
    classesDir.mkdirs();
    writeFile(baseFile, baseText);
    String[] javacArgs = {"-d", classesDir.getPath(), baseFile.getPath()};
    com.sun.tools.javac.Main.compile(javacArgs);

    writeFile(srcFile, srcText);
    String[] args = {
      "-d", "api", "-classpath", classesDir.getPath(), "-package", "p", srcFile.getPath()
    };

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream prev = System.err;
    System.setErr(ps);
    try {
      int rc = com.sun.tools.javadoc.Main.execute(args);
    } finally {
      System.err.flush();
      System.setErr(prev);
    }
    String out = baos.toString();
    System.out.println(out);

    String errorMessage = "java.lang.IllegalArgumentException: <clinit>";
    if (out.contains(errorMessage)) throw new Exception("error message found: " + errorMessage);
  }
示例#2
0
 /** Run javadoc */
 public static void runJavadoc(String[] javadocArgs) {
   if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
     throw new Error("Javadoc failed to execute");
   }
 }