void run() throws IOException, InterruptedException {
String PS = File.pathSeparator;
write(new File("A.java"), "class A { }");
write(new File("B.java"), "class B extends A { }"); // In the following line, the presence of the empty element // should not mask the presence of the "." element on the path
javac("-verbose", "-sourcepath", "" + PS + ".", "B.java");
}
void javac(String... args) throws IOException, InterruptedException {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw); int rc = com.sun.tools.javac.Main.compile(args, out);
System.out.println(sw.toString()); if (rc != 0) thrownew Error("javac failed: rc=" + rc);
}
void write(File to, String body) throws IOException {
System.err.println("write " + to);
File toDir = to.getParentFile(); if (toDir != null) { boolean ok = toDir.mkdirs(); if (!ok) { thrownew Error("could not create directory " + toDir);
}
}
Writer out = new FileWriter(to); try {
out.write(body); if (!body.endsWith("\n"))
out.write("\n");
} finally {
out.close();
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.