Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/tool/MultiReleaseJar/TestMultiRelease.java
40971 views
1
/*
2
* Copyright (c) 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
*/
23
24
/*
25
* @test
26
* @bug 8208269
27
* @summary Verify module-infos are read from the correct place in multi-release jars
28
* @library /tools/lib
29
* @modules jdk.compiler/com.sun.tools.javac.api
30
* jdk.compiler/com.sun.tools.javac.main
31
* jdk.javadoc/jdk.javadoc.internal.api
32
* jdk.javadoc/jdk.javadoc.internal.tool
33
* @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox
34
* @run main TestMultiRelease
35
*/
36
37
import java.io.IOException;
38
import java.nio.file.Files;
39
import java.nio.file.Path;
40
import java.nio.file.Paths;
41
import java.util.Arrays;
42
43
import toolbox.JarTask;
44
import toolbox.JavacTask;
45
import toolbox.JavadocTask;
46
import toolbox.Task.Expect;
47
import toolbox.TestRunner;
48
import toolbox.ToolBox;
49
50
public class TestMultiRelease extends TestRunner {
51
52
public static void main(String... args) throws Exception {
53
TestMultiRelease t = new TestMultiRelease();
54
t.runTests(m -> new Object[] { Paths.get(m.getName()) });
55
}
56
57
private final ToolBox tb = new ToolBox();
58
59
TestMultiRelease() throws IOException {
60
super(System.err);
61
}
62
63
@Test
64
public void testMultiReleaseModule(Path base) throws Exception {
65
Files.createDirectory(base);
66
67
Path module = base.resolve("module");
68
Path moduleSrc = module.resolve("src");
69
Path moduleCls = module.resolve("classes");
70
71
tb.writeJavaFiles(moduleSrc, "module test.module { }");
72
73
Files.createDirectories(moduleCls);
74
75
new JavacTask(tb)
76
.outdir(moduleCls)
77
.files(tb.findJavaFiles(moduleSrc))
78
.run()
79
.writeAll();
80
81
Path moduleJarDir = module.resolve("jar-dir");
82
Path versions = moduleJarDir.resolve("META-INF/versions/10");
83
84
Files.createDirectories(versions);
85
86
Files.copy(moduleCls.resolve("module-info.class"),
87
versions.resolve("module-info.class"));
88
89
Path moduleJar = module.resolve("module.jar");
90
91
new JarTask(tb, moduleJar)
92
.baseDir(moduleJarDir)
93
.files(Arrays.stream(tb.findFiles("class", moduleJarDir))
94
.map(p -> moduleJarDir.relativize(p).toString())
95
.toArray(s -> new String[s]))
96
.manifest("Multi-Release: true\n\n")
97
.run();
98
99
Path src = base.resolve("src");
100
101
tb.writeJavaFiles(src,
102
"module m { requires test.module; exports api; }",
103
"package api; public class Api { }");
104
Path out = base.resolve("out");
105
Files.createDirectory(out);
106
107
JavadocTask task = new JavadocTask(tb);
108
task.outdir(out)
109
.options("--module-path", moduleJar.toString(),
110
"-source", "10")
111
.files(tb.findJavaFiles(src))
112
.run(Expect.SUCCESS);
113
114
task.outdir(out)
115
.options("--module-path", moduleJar.toString(),
116
"-source", "9")
117
.files(tb.findJavaFiles(src))
118
.run(Expect.FAIL);
119
}
120
}
121
122