1 /* |
1 /* |
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 * @test |
25 * @test |
26 * @bug 6558476 5071352 |
26 * @bug 6558476 5071352 |
27 * @summary com/sun/tools/javac/Main.compile don't release file handles on return |
27 * @summary com/sun/tools/javac/Main.compile don't release file handles on return |
28 * @library /tools/lib |
28 * @library /tools/lib |
29 * @modules jdk.compiler/com.sun.tools.javac.api |
29 * @modules jdk.compiler/com.sun.tools.javac.api |
30 * jdk.compiler/com.sun.tools.javac.file |
|
31 * jdk.compiler/com.sun.tools.javac.main |
30 * jdk.compiler/com.sun.tools.javac.main |
32 * jdk.jdeps/com.sun.tools.javap |
31 * jdk.jdeps/com.sun.tools.javap |
33 * @build ToolBox |
32 * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask |
34 * @run main/othervm -Xmx512m -Xms512m T6558476 |
33 * @run main/othervm -Xmx512m -Xms512m T6558476 |
35 */ |
34 */ |
36 |
35 |
37 import java.io.File; |
36 import java.io.File; |
38 import java.io.FileInputStream; |
37 import java.io.FileInputStream; |
39 import java.io.FileOutputStream; |
38 import java.io.FileOutputStream; |
40 import java.io.IOException; |
39 import java.io.IOException; |
41 import java.util.Random; |
40 import java.util.Random; |
42 |
41 |
43 import com.sun.tools.javac.Main; |
42 import com.sun.tools.javac.Main; |
|
43 |
|
44 import toolbox.JarTask; |
|
45 import toolbox.JavacTask; |
|
46 import toolbox.ToolBox; |
44 |
47 |
45 public class T6558476 { |
48 public class T6558476 { |
46 |
49 |
47 private static final String classFoo = "class Foo {}"; |
50 private static final String classFoo = "class Foo {}"; |
48 private static final String classMyFoo = |
51 private static final String classMyFoo = |
53 "}"; |
56 "}"; |
54 |
57 |
55 public static void main(String[] args) throws IOException { |
58 public static void main(String[] args) throws IOException { |
56 ToolBox tb = new ToolBox(); |
59 ToolBox tb = new ToolBox(); |
57 |
60 |
58 tb.new JavacTask() |
61 new JavacTask(tb) |
59 .sources(classFoo) |
62 .sources(classFoo) |
60 .run(); |
63 .run(); |
61 tb.new JarTask("foo.jar") |
64 new JarTask(tb, "foo.jar") |
62 .files("Foo.class") |
65 .files("Foo.class") |
63 .run(); |
66 .run(); |
64 |
67 |
65 tb.new JavacTask() |
68 new JavacTask(tb) |
66 .classpath("foo.jar") |
69 .classpath("foo.jar") |
67 .sources(classMyFoo) |
70 .sources(classMyFoo) |
68 .run(); |
71 .run(); |
69 File foo_jar = new File("foo.jar"); |
72 File foo_jar = new File("foo.jar"); |
70 if (foo_jar.delete()) { |
73 if (foo_jar.delete()) { |
71 System.out.println("jar file successfully deleted"); |
74 System.out.println("jar file successfully deleted"); |
72 } else { |
75 } else { |
73 throw new Error("Error deleting file \"" + foo_jar.getPath() + "\""); |
76 throw new Error("Error deleting file \"" + foo_jar.getPath() + "\""); |