mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8050429: Update/cleanup ToolBox
Reviewed-by: vromero
This commit is contained in:
parent
14fcc1d07d
commit
33e6564a6b
54 changed files with 2577 additions and 1792 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue