author | sogoel |
Fri, 29 Aug 2014 00:42:42 -0700 | |
changeset 26274 | 02a5b23ee21c |
parent 26100 | bb7dd001d190 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
1 |
/* |
26100 | 2 |
* Copyright (c) 2013, 2014, 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 |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
29 |
* @build ToolBox |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
30 |
* @run main InnerClassFileTest |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
31 |
*/ |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
32 |
|
26100 | 33 |
import java.nio.file.Path; |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
34 |
import java.nio.file.Paths; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
35 |
|
26100 | 36 |
// Original test: test/tools/javac/innerClassFile/Driver.sh |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
37 |
public class InnerClassFileTest { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
38 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
39 |
private static final String BSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
40 |
"package x;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
41 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
42 |
"import x.*;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
43 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
44 |
"public class B {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
45 |
" public static class C {}\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
46 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
47 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
48 |
private static final String CSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
49 |
"package x;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
50 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
51 |
"import x.*;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
52 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
53 |
"public class C {}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
54 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
55 |
private static final String MainSrc = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
56 |
"package y;\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 |
"class Main {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
59 |
" private R1 a;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
60 |
" private R2 b;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
61 |
" private R3 c;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
62 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
63 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
64 |
private static final String R1Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
65 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
66 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
67 |
"public final class R1 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
68 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
69 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
70 |
" R2 c = new R2();\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
71 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
72 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
73 |
private static final String R2Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
74 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
75 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
76 |
"public final class R2 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
77 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
78 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
79 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
80 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
81 |
private static final String R3Src = |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
82 |
"package y;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
83 |
"\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
84 |
"public final class R3 {\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
85 |
" x.B.C a = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
86 |
" x.C b = null;\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
87 |
" R1 c = new R1();\n" + |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
88 |
"}"; |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
89 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
90 |
public static void main(String args[]) throws Exception { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
91 |
new InnerClassFileTest().run(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
92 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
93 |
|
26100 | 94 |
private final ToolBox tb = new ToolBox(); |
95 |
||
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
96 |
void run() throws Exception { |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
97 |
createFiles(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
98 |
compileFiles(); |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
99 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
100 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
101 |
void createFiles() throws Exception { |
26100 | 102 |
Path srcDir = Paths.get("src"); |
103 |
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
|
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 compileFiles() throws Exception { |
26100 | 107 |
tb.new JavacTask() |
108 |
.outdir(".") |
|
109 |
.classpath(".") |
|
110 |
.sourcepath("src") |
|
111 |
.files("src/x/B.java", "src/x/C.java", "src/y/Main.java") |
|
112 |
.run() |
|
113 |
.writeAll(); |
|
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
114 |
|
26100 | 115 |
tb.deleteFiles("y/R3.class"); |
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
116 |
|
26100 | 117 |
tb.new JavacTask() |
118 |
.outdir(".") |
|
119 |
.classpath(".") |
|
120 |
.sourcepath("src") |
|
121 |
.files("src/y/Main.java") |
|
122 |
.run() |
|
123 |
.writeAll(); |
|
124 |
||
16304
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
125 |
} |
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
126 |
|
475504933a2d
8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff
changeset
|
127 |
} |