8217385: JTREG: Clean up, make sure to close resources

Reviewed-by: tschatzl, sangheki
This commit is contained in:
Leo Korinth 2019-02-18 10:48:48 +01:00
parent 29021027db
commit 3d13ab6882
3 changed files with 36 additions and 33 deletions

View File

@ -156,6 +156,7 @@ public class TestHumongousClassLoader {
URLClassLoader urlLoader = new URLClassLoader(url);
Class<?> simpleClassLoaderClass = urlLoader.loadClass(SIMPLE_CLASSLOADER_NAME);
urlLoader.close();
ClassLoader simpleClassLoader = (ClassLoader) simpleClassLoaderClass
.getConstructor(java.lang.ClassLoader.class)

View File

@ -95,7 +95,7 @@ final public class LogParser {
}
private PlabReport parseLines() throws NumberFormatException {
Scanner lineScanner = new Scanner(log);
try (Scanner lineScanner = new Scanner(log)) {
PlabReport plabReport = new PlabReport();
Optional<Long> gc_id;
while (lineScanner.hasNextLine()) {
@ -126,6 +126,7 @@ final public class LogParser {
}
return plabReport;
}
}
private static Optional<Long> getGcId(String line, Pattern pattern) {
Matcher number = pattern.matcher(line);

View File

@ -38,7 +38,7 @@ public class TestGCBasher {
HashMap<String, ClassInfo> deps = new HashMap<>();
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
Stream<Path> s = Files.walk(fs.getPath("/"));
try (Stream<Path> s = Files.walk(fs.getPath("/"))) {
for (Path p : (Iterable<Path>)s::iterator) {
if (p.toString().endsWith(".class") &&
!p.getFileName().toString().equals("module-info.class")) {
@ -49,6 +49,7 @@ public class TestGCBasher {
}
}
}
}
public static void main(String[] args) throws IOException {
if (args.length != 1) {