8050429: Update/cleanup ToolBox

Reviewed-by: vromero
This commit is contained in:
Jonathan Gibbons 2014-08-13 13:20:31 -07:00
parent 14fcc1d07d
commit 33e6564a6b
54 changed files with 2577 additions and 1792 deletions

View file

@ -25,19 +25,18 @@
* @test
* @bug 8023945
* @summary javac wrongly allows a subclass of an anonymous class
* @library /tools/javac/lib
* @library /tools/lib
* @build ToolBox
* @run main AnonymousSubclassTest
*/
import java.util.ArrayList;
import java.io.IOException;
public class AnonymousSubclassTest {
public static void main(String... args) throws Exception {
new AnonymousSubclassTest().run();
}
ToolBox tb = new ToolBox();
// To trigger the error we want, first we need to compile
// a class with an anonymous inner class: Foo$1.
final String foo =
@ -65,20 +64,21 @@ public class AnonymousSubclassTest {
"}";
void compOk(String code) throws Exception {
ToolBox.javac(new ToolBox.JavaToolArgs().setSources(code));
tb.new JavacTask()
.sources(code)
.run();
}
void compFail(String code) throws Exception {
ArrayList<String> errors = new ArrayList<>();
ToolBox.JavaToolArgs args = new ToolBox.JavaToolArgs();
args.setSources(code)
.appendArgs("-cp", ".", "-XDrawDiagnostics")
.set(ToolBox.Expect.FAIL)
.setErrOutput(errors);
ToolBox.javac(args);
String errs = tb.new JavacTask()
.sources(code)
.classpath(".")
.options("-XDrawDiagnostics")
.run(ToolBox.Expect.FAIL)
.writeAll()
.getOutput(ToolBox.OutputKind.DIRECT);
if (!errors.get(0).contains("cant.inherit.from.anon")) {
System.out.println(errors.get(0));
if (!errs.contains("cant.inherit.from.anon")) {
throw new Exception("test failed");
}
}