author | duke |
Wed, 05 Jul 2017 20:10:53 +0200 | |
changeset 27979 | cc2cf80c2f39 |
parent 27579 | d1a63c99cdd5 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
1 |
/* |
27579 | 2 |
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
4 |
* |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
8 |
* |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
14 |
* |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
18 |
* |
5520 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
22 |
*/ |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
23 |
|
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
24 |
/* |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
25 |
* @test |
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
26 |
* @bug 6558476 5071352 |
16800 | 27 |
* @summary com/sun/tools/javac/Main.compile don't release file handles on return |
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
28 |
* @library /tools/lib |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
29 |
* @build ToolBox |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
30 |
* @run main/othervm -Xmx512m -Xms512m T6558476 |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
31 |
*/ |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
32 |
|
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
33 |
import java.io.File; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
34 |
import java.io.FileInputStream; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
35 |
import java.io.FileOutputStream; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
36 |
import java.io.IOException; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
37 |
import java.util.Random; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
38 |
|
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
39 |
import com.sun.tools.javac.Main; |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
40 |
|
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
41 |
public class T6558476 { |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
42 |
|
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
43 |
private static final String classFoo = "class Foo {}"; |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
44 |
private static final String classMyFoo = |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
45 |
"class MyFoo {\n" + |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
46 |
" public static void main(String[] args) {\n"+ |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
47 |
" new Foo();\n"+ |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
48 |
" }\n"+ |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
49 |
"}"; |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
50 |
|
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
51 |
public static void main(String[] args) throws IOException { |
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
52 |
ToolBox tb = new ToolBox(); |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
53 |
|
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
54 |
tb.new JavacTask() |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
55 |
.sources(classFoo) |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
56 |
.run(); |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
57 |
tb.new JarTask("foo.jar") |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
58 |
.files("Foo.class") |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
59 |
.run(); |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
60 |
|
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
61 |
tb.new JavacTask() |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
62 |
.classpath("foo.jar") |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
63 |
.sources(classMyFoo) |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
64 |
.run(); |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
65 |
File foo_jar = new File("foo.jar"); |
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
66 |
if (foo_jar.delete()) { |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
67 |
System.out.println("jar file successfully deleted"); |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
68 |
} else { |
27234
f3f667e5870c
8059423: Replace references for rt.jar by temp.jar
sogoel
parents:
16800
diff
changeset
|
69 |
throw new Error("Error deleting file \"" + foo_jar.getPath() + "\""); |
3656
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
70 |
} |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
71 |
} |
d4e34b76b0c3
6558476: com/sun/tools/javac/Main.compile don't release file handles on return
jjg
parents:
diff
changeset
|
72 |
} |