2
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
* @summary tests for subpackage issues
29
* jdk.compiler/com.sun.tools.javac.api
30
* jdk.compiler/com.sun.tools.javac.main
31
* @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
32
* @run main SubpackageTest
35
import java.nio.file.Files;
36
import java.nio.file.Path;
37
import java.util.ArrayList;
38
import java.util.Arrays;
39
import java.util.Collections;
41
import java.util.stream.Collectors;
43
import toolbox.JavacTask;
45
import toolbox.ToolBox;
47
public class SubpackageTest extends ModuleTestBase {
49
public static void main(String... args) throws Exception {
50
SubpackageTest t = new SubpackageTest();
54
@Test // based on JDK-8075435
55
public void testUnnamedModule(Path base) throws Exception {
56
Path libsrc = base.resolve("lib/src");
57
tb.writeJavaFiles(libsrc,
58
"package p; public class E extends Error { }");
59
Path libclasses = base.resolve("lib/classes");
60
Files.createDirectories(libclasses);
63
.files(findJavaFiles(libsrc))
67
Path src = base.resolve("src");
68
tb.writeJavaFiles(src,
73
void m() { throw new E(); }
75
Path classes = base.resolve("classes");
76
Files.createDirectories(classes);
79
.classpath(libclasses)
81
.files(findJavaFiles(src))
87
public void testSimpleMulti(Path base) throws Exception {
88
Path src = base.resolve("src");
89
tb.writeJavaFiles(src.resolve("mp"),
90
"module mp { exports p; }",
91
"package p; public class C1 { }");
92
tb.writeJavaFiles(src.resolve("mpq"),
93
"module mpq { exports p.q; }",
94
"package p.q; public class C2 { }");
95
tb.writeJavaFiles(src.resolve("mpqr"),
96
"module mpqr { exports p.q.r; }",
97
"package p.q.r; public class C3 { }");
98
tb.writeJavaFiles(src.resolve("m"),
100
module m { requires mp;
111
Path modules = base.resolve("modules");
112
Files.createDirectories(modules);
115
.options("--module-source-path", src.toString())
117
.files(findJavaFiles(src))