1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
104 List<String> expectedOut = Arrays.asList(
105 "Test.java:1:57: compiler.err.cant.access: test.Broken, (compiler.misc.bad.class.file.header: Broken.class, (compiler.misc.class.file.wrong.class: java.lang.AutoCloseable))",
106 "Test.java:1:73: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, java.lang.String, null)",
107 "2 errors"
108 );
109
110 if (!expectedOut.equals(log))
111 throw new Exception("expected output not found: " + log);
112 }
113
114 @Test
115 public void testLoading(Path base) throws Exception {
116 Path src = base.resolve("src");
117 tb.writeJavaFiles(src,
118 "public class Test { static { new Object() {}; } public static class I { public static class II { } } }");
119 Path out = base.resolve("out");
120 tb.createDirectories(out);
121
122 new toolbox.JavacTask(tb)
123 .outdir(out)
124 .files(tb.findJavaFiles(src))
125 .run(Expect.SUCCESS)
126 .writeAll()
127 .getOutputLines(Task.OutputKind.DIRECT);
128
129 List<Path> files;
130 try (Stream<Path> dir = Files.list(out)) {
131 files = dir.collect(Collectors.toList());
132 }
133
134 List<List<Path>> result = new ArrayList<>();
135
136 permutations(files, Collections.emptyList(), result);
137
138 for (List<Path> order : result) {
139 for (Path missing : order) {
140 Path test = base.resolve("test");
141
142 if (Files.exists(test)) {
143 tb.cleanDirectory(test);
|
1 /*
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
104 List<String> expectedOut = Arrays.asList(
105 "Test.java:1:57: compiler.err.cant.access: test.Broken, (compiler.misc.bad.class.file.header: Broken.class, (compiler.misc.class.file.wrong.class: java.lang.AutoCloseable))",
106 "Test.java:1:73: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, java.lang.String, null)",
107 "2 errors"
108 );
109
110 if (!expectedOut.equals(log))
111 throw new Exception("expected output not found: " + log);
112 }
113
114 @Test
115 public void testLoading(Path base) throws Exception {
116 Path src = base.resolve("src");
117 tb.writeJavaFiles(src,
118 "public class Test { static { new Object() {}; } public static class I { public static class II { } } }");
119 Path out = base.resolve("out");
120 tb.createDirectories(out);
121
122 new toolbox.JavacTask(tb)
123 .outdir(out)
124 .options("-source", "10", "-target", "10")
125 .files(tb.findJavaFiles(src))
126 .run(Expect.SUCCESS)
127 .writeAll()
128 .getOutputLines(Task.OutputKind.DIRECT);
129
130 List<Path> files;
131 try (Stream<Path> dir = Files.list(out)) {
132 files = dir.collect(Collectors.toList());
133 }
134
135 List<List<Path>> result = new ArrayList<>();
136
137 permutations(files, Collections.emptyList(), result);
138
139 for (List<Path> order : result) {
140 for (Path missing : order) {
141 Path test = base.resolve("test");
142
143 if (Files.exists(test)) {
144 tb.cleanDirectory(test);
|