8062514: Update ToolTester tests to close file manager
Reviewed-by: darcy
This commit is contained in:
parent
4ce27b2f9e
commit
342df9829a
@ -130,6 +130,8 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
if (register)
|
||||
context.put(JavaFileManager.class, this);
|
||||
setContext(context);
|
||||
if (System.getProperty("show.fm.open.close") != null)
|
||||
System.err.println("JavacFileManager.open " + this.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -571,6 +573,8 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
*/
|
||||
@DefinedBy(Api.COMPILER)
|
||||
public void close() {
|
||||
if (System.getProperty("show.fm.open.close") != null)
|
||||
System.err.println("JavacFileManager.close " + this.hashCode());
|
||||
for (Iterator<Archive> i = archives.values().iterator(); i.hasNext(); ) {
|
||||
Archive a = i.next();
|
||||
i.remove();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -106,6 +106,8 @@ public class T6406133 extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new T6406133().test();
|
||||
try (T6406133 t = new T6406133()) {
|
||||
t.test();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
* @run main T6410643
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.tools.JavaFileObject;
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
@ -68,7 +69,10 @@ public class T6410643 extends ToolTester {
|
||||
testGetTask(s, s, f);
|
||||
System.err.println("Test result: PASSED");
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6410643().test(args);
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6410643 t = new T6410643()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -54,6 +54,8 @@ public class T6411310 extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
new T6411310().test(args);
|
||||
try (T6411310 t = new T6411310()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -82,7 +82,10 @@ public class T6411333 extends ToolTester {
|
||||
testRelativeUri("util/List.java", false);
|
||||
testRelativeUri("/util/List.java", true);
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6411333().test(args);
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6411333 t = new T6411333()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@
|
||||
* @run main T6412656
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.Collections;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
@ -52,8 +53,10 @@ public class T6412656 extends ToolTester {
|
||||
System.out.println("OK");
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
new T6412656().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6412656 t = new T6412656()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
* @run main T6415780
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import static javax.tools.StandardLocation.CLASS_PATH;
|
||||
|
||||
public class T6415780 extends ToolTester {
|
||||
@ -39,8 +40,9 @@ public class T6415780 extends ToolTester {
|
||||
System.out.println(fm.getClassLoader(CLASS_PATH).toString()); // null-check
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
T6415780 tester = new T6415780();
|
||||
tester.test();
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6415780 tester = new T6415780()) {
|
||||
tester.test();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
* @run main T6418694
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
public class T6418694 extends ToolTester {
|
||||
@ -52,7 +53,9 @@ public class T6418694 extends ToolTester {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6418694().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6418694 t = new T6418694()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -101,8 +102,10 @@ public class T6421111 extends ToolTester {
|
||||
return SourceVersion.latest();
|
||||
}
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6421111().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6421111 t = new T6421111()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
public static AssertionError error(String format, Object... args) {
|
||||
return new AssertionError(String.format(format, args));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
* @run main T6421756
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
public class T6421756 extends ToolTester {
|
||||
@ -44,7 +45,9 @@ public class T6421756 extends ToolTester {
|
||||
System.out.println("OK: got expected error " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6421756().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6421756 t = new T6421756()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,7 +46,9 @@ public class T6422215 extends ToolTester {
|
||||
System.out.println("OK: caught expected exception: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6422215().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6422215 t = new T6422215()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class T6422327 extends ToolTester {
|
||||
void test(String... args) {
|
||||
@ -43,7 +44,9 @@ public class T6422327 extends ToolTester {
|
||||
System.err.println("OK, got expected exception: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6422327().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6422327 t = new T6422327()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
* @run main T6423003
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class T6423003 extends ToolTester {
|
||||
@ -44,7 +45,9 @@ public class T6423003 extends ToolTester {
|
||||
}
|
||||
throw new AssertionError("Expected IllegalStateException not thrown");
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6423003().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6423003 t = new T6423003()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -67,6 +67,8 @@ public class T6431257 extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
new T6431257().test(args);
|
||||
try (T6431257 t = new T6431257()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -51,6 +51,8 @@ public class T6437349 extends ToolTester {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static void main(String... args) throws IOException {
|
||||
new T6437349().test(args);
|
||||
try (T6437349 t = new T6437349()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -86,6 +86,8 @@ public class T6437999 extends ToolTester {
|
||||
throw new AssertionError("Error in UTF-8 mode");
|
||||
}
|
||||
public static void main(String... args) throws IOException {
|
||||
new T6437999().test(args);
|
||||
try (T6437999 t = new T6437999()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,6 +50,8 @@ public class T6440333 extends ToolTester {
|
||||
}
|
||||
}
|
||||
public static void main(String... args) throws IOException {
|
||||
new T6440333().test(args);
|
||||
try (T6440333 t = new T6440333()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -66,6 +66,8 @@ public class T6440528 extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new T6440528().test(args);
|
||||
try (T6440528 t = new T6440528()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -88,8 +88,10 @@ public class T6468404 extends ToolTester {
|
||||
if (!task.call())
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static void main(String... args) {
|
||||
new T6468404().test(args);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6468404 t = new T6468404()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -106,6 +106,8 @@ public class T6731573 extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new T6731573().test();
|
||||
try (T6731573 t = new T6731573()) {
|
||||
t.test();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@
|
||||
* @run main T6733837
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URI;
|
||||
@ -43,8 +44,10 @@ import com.sun.source.util.JavacTask;
|
||||
|
||||
public class T6733837 extends ToolTester {
|
||||
|
||||
public static void main(String... args) {
|
||||
new T6733837().exec();
|
||||
public static void main(String... args) throws IOException {
|
||||
try (T6733837 t = new T6733837()) {
|
||||
t.exec();
|
||||
}
|
||||
}
|
||||
|
||||
public void exec() {
|
||||
|
@ -115,7 +115,9 @@ public class TestJavacTaskScanner extends ToolTester {
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
String srcdir = System.getProperty("test.src");
|
||||
new TestJavacTaskScanner(new File(srcdir, args[0])).run();
|
||||
try (TestJavacTaskScanner t = new TestJavacTaskScanner(new File(srcdir, args[0]))) {
|
||||
t.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void testGetAllMembers(TypeElement clazz) {
|
||||
|
@ -51,7 +51,9 @@ import com.sun.tools.javac.api.JavacTaskImpl;
|
||||
*/
|
||||
public class TestResolveError extends ToolTester {
|
||||
public static void main(String... args) throws Exception {
|
||||
new TestResolveError().run();
|
||||
try (TestResolveError t = new TestResolveError()) {
|
||||
t.run();
|
||||
}
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -80,7 +80,9 @@ public class Test extends ToolTester {
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
new Test().test(args);
|
||||
try (Test t = new Test()) {
|
||||
t.test(args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,7 @@ import static javax.tools.StandardLocation.CLASS_PATH;
|
||||
import static javax.tools.StandardLocation.SOURCE_PATH;
|
||||
import static javax.tools.StandardLocation.CLASS_OUTPUT;
|
||||
|
||||
public class ToolTester {
|
||||
public class ToolTester implements AutoCloseable {
|
||||
public final File test_src = new File(System.getProperty("test.src", "."));
|
||||
public final File test_classes = new File(System.getProperty("test.classes", "."));
|
||||
public final List<File> test_class_path = pathToFiles(System.getProperty("test.class.path"),
|
||||
@ -77,4 +77,9 @@ public class ToolTester {
|
||||
result.addAll(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user