Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/tool/modules/MissingSourceModules.java
40974 views
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
*/
23
24
/*
25
* @test
26
* @bug 8176481 8246705
27
* @summary Tests behavior of the tool, when modules are present as
28
* binaries.
29
* @modules
30
* jdk.javadoc/jdk.javadoc.internal.api
31
* jdk.javadoc/jdk.javadoc.internal.tool
32
* jdk.compiler/com.sun.tools.javac.api
33
* jdk.compiler/com.sun.tools.javac.main
34
* @library /tools/lib
35
* @build toolbox.ToolBox toolbox.TestRunner
36
* @run main MissingSourceModules
37
*/
38
39
import java.nio.file.Path;
40
import java.nio.file.Paths;
41
42
import toolbox.*;
43
44
public class MissingSourceModules extends ModuleTestBase {
45
46
public static void main(String... args) throws Exception {
47
new MissingSourceModules().runTests();
48
}
49
50
@Test
51
public void testExplicitBinaryModuleOnModulePath(Path base) throws Exception {
52
Path modulePath = base.resolve("modules");
53
54
ModuleBuilder ma = new ModuleBuilder(tb, "ma");
55
ma.comment("Module ma.")
56
.exports("pkg1")
57
.classes("package pkg1; /** Class A */ public class A { }")
58
.classes("package pkg1.pkg2; /** Class B */ public class B { }")
59
.build(modulePath);
60
61
execNegativeTask("--module-path", modulePath.toString(),
62
"--module", "ma");
63
assertMessagePresent("module ma not found");
64
}
65
66
@Test
67
public void testExplicitBinaryModuleOnLegacyPaths(Path base) throws Exception {
68
Path modulePath = base.resolve("modules");
69
70
ModuleBuilder ma = new ModuleBuilder(tb, "ma");
71
ma.comment("Module ma.")
72
.exports("pkg1")
73
.classes("package pkg1; /** Class A */ public class A { }")
74
.classes("package pkg1.pkg2; /** Class B */ public class B { }")
75
.build(modulePath);
76
77
Path mPath = Paths.get(modulePath.toString(), "ma");
78
execNegativeTask("--source-path", mPath.toString(),
79
"--module", "ma");
80
assertMessagePresent("module ma not found on source path");
81
82
execNegativeTask("--class-path", mPath.toString(),
83
"--module", "ma");
84
assertMessagePresent("module ma not found");
85
}
86
87
@Test
88
public void testImplicitBinaryRequiresModule(Path base) throws Exception {
89
Path src = base.resolve("src");
90
Path modulePath = base.resolve("modules");
91
92
ModuleBuilder mb = new ModuleBuilder(tb, "mb");
93
mb.comment("Module mb.")
94
.exports("pkgb")
95
.classes("package pkgb; /** Class A */ public class A { }")
96
.build(modulePath);
97
98
ModuleBuilder ma = new ModuleBuilder(tb, "ma");
99
ma.comment("Module ma.")
100
.exports("pkga")
101
.requires("mb", modulePath)
102
.classes("package pkga; /** Class A */ public class A { }")
103
.write(src);
104
105
execTask("--module-path", modulePath.toString(),
106
"--module-source-path", src.toString(),
107
"--expand-requires", "all",
108
"--module", "ma");
109
assertMessagePresent("source files for module mb not found");
110
}
111
112
@Test
113
public void testImplicitBinaryTransitiveModule(Path base) throws Exception {
114
Path src = base.resolve("src");
115
Path modulePath = base.resolve("modules");
116
117
ModuleBuilder mb = new ModuleBuilder(tb, "mb");
118
mb.comment("Module mb.")
119
.exports("pkgb")
120
.classes("package pkgb; /** Class A */ public class A { }")
121
.build(modulePath);
122
123
ModuleBuilder ma = new ModuleBuilder(tb, "ma");
124
ma.comment("Module ma.")
125
.exports("pkga")
126
.requiresTransitive("mb", modulePath)
127
.classes("package pkga; /** Class A */ public class A { }")
128
.write(src);
129
130
execTask("--module-path", modulePath.toString(),
131
"--module-source-path", src.toString(),
132
"--expand-requires", "transitive",
133
"--module", "ma");
134
assertMessagePresent("source files for module mb not found");
135
}
136
}
137
138