author | mcimadamore |
Wed, 26 Oct 2016 15:41:25 +0100 | |
changeset 41856 | 13a056e8f16e |
parent 36778 | e04318f39f92 |
permissions | -rw-r--r-- |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
1 |
/* |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
4 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
8 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
14 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
18 |
* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
21 |
* questions. |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
22 |
*/ |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
23 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
24 |
/* |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
25 |
* @test |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
26 |
* @bug 4491755 4785453 |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
27 |
* @summary Prob w/static inner class with same name as a regular class |
26100 | 28 |
* @library /tools/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
31 |
* @build toolbox.ToolBox toolbox.JavacTask |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
32 |
* @run main InnerClassFileTest |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
33 |
*/ |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
34 |
|
26100 | 35 |
import java.nio.file.Path; |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
37 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
38 |
import toolbox.JavacTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
39 |
import toolbox.ToolBox; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
40 |
|
26100 | 41 |
// Original test: test/tools/javac/innerClassFile/Driver.sh |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
42 |
public class InnerClassFileTest { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
43 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
44 |
private static final String BSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
45 |
"package x;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
46 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
47 |
"import x.*;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
48 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
49 |
"public class B {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
50 |
" public static class C {}\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
51 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
52 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
53 |
private static final String CSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
54 |
"package x;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
55 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
56 |
"import x.*;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
57 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
58 |
"public class C {}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
59 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
60 |
private static final String MainSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
61 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
62 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
63 |
"class Main {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
64 |
" private R1 a;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
65 |
" private R2 b;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
66 |
" private R3 c;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
67 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
68 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
69 |
private static final String R1Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
70 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
71 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
72 |
"public final class R1 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
73 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
74 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
75 |
" R2 c = new R2();\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
76 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
77 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
78 |
private static final String R2Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
79 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
80 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
81 |
"public final class R2 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
82 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
83 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
84 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
85 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
86 |
private static final String R3Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
87 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
88 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
89 |
"public final class R3 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
90 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
91 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
92 |
" R1 c = new R1();\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
93 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
94 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
95 |
public static void main(String args[]) throws Exception { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
96 |
new InnerClassFileTest().run(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
97 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
98 |
|
26100 | 99 |
private final ToolBox tb = new ToolBox(); |
100 |
||
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
101 |
void run() throws Exception { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
102 |
createFiles(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
103 |
compileFiles(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
104 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
105 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
106 |
void createFiles() throws Exception { |
26100 | 107 |
Path srcDir = Paths.get("src"); |
108 |
tb.writeJavaFiles(srcDir, BSrc, CSrc, MainSrc, R1Src, R2Src, R3Src); |
|
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
109 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
110 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
111 |
void compileFiles() throws Exception { |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
112 |
new JavacTask(tb) |
26100 | 113 |
.outdir(".") |
114 |
.classpath(".") |
|
115 |
.sourcepath("src") |
|
116 |
.files("src/x/B.java", "src/x/C.java", "src/y/Main.java") |
|
117 |
.run() |
|
118 |
.writeAll(); |
|
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
119 |
|
26100 | 120 |
tb.deleteFiles("y/R3.class"); |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
121 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
122 |
new JavacTask(tb) |
26100 | 123 |
.outdir(".") |
124 |
.classpath(".") |
|
125 |
.sourcepath("src") |
|
126 |
.files("src/y/Main.java") |
|
127 |
.run() |
|
128 |
.writeAll(); |
|
129 |
||
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
130 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
131 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
132 |
} |