Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jlink/ExplodedModuleNameTest.java
41145 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
import java.io.IOException;
25
import java.nio.file.attribute.BasicFileAttributes;
26
import java.nio.file.Files;
27
import java.nio.file.FileVisitResult;
28
import java.nio.file.Path;
29
import java.nio.file.SimpleFileVisitor;
30
import java.util.spi.ToolProvider;
31
32
import tests.Helper;
33
import tests.JImageGenerator;
34
import tests.Result;
35
36
/*
37
* @test
38
* @bug 8192986
39
* @summary Inconsistent handling of exploded modules in jlink
40
* @library ../lib
41
* @modules java.base/jdk.internal.jimage
42
* jdk.jdeps/com.sun.tools.classfile
43
* jdk.jlink/jdk.tools.jlink.internal
44
* jdk.jlink/jdk.tools.jmod
45
* jdk.jlink/jdk.tools.jimage
46
* jdk.compiler
47
* @build tests.*
48
* @run main ExplodedModuleNameTest
49
*/
50
public class ExplodedModuleNameTest {
51
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
52
.orElseThrow(() ->
53
new RuntimeException("jlink tool not found")
54
);
55
56
public static void main(String[] args) throws Exception {
57
Helper helper = Helper.newHelper();
58
if (helper == null) {
59
System.err.println("Test not run");
60
return;
61
}
62
63
// generate a new exploded module
64
String modName = "mod8192986";
65
Path modDir = helper.generateDefaultExplodedModule(modName).getFile();
66
// rename the module containing directory
67
Path renamedModDir = modDir.resolveSibling("modified_mod8192986");
68
// copy the content from original directory to modified name directory
69
copyDir(modDir, renamedModDir);
70
71
Path outputDir = helper.createNewImageDir("image8192986");
72
JImageGenerator.getJLinkTask()
73
.modulePath(renamedModDir.toAbsolutePath().toString())
74
.output(outputDir)
75
.addMods(modName)
76
.launcher(modName + "=" + modName + "/" + modName +".Main")
77
.call().assertSuccess();
78
}
79
80
private static void copyDir(Path srcDir, Path destDir) throws IOException {
81
Files.walkFileTree(srcDir, new SimpleFileVisitor<Path>() {
82
@Override
83
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
84
Path target = destDir.resolve(srcDir.relativize(dir));
85
Files.createDirectory(target);
86
return FileVisitResult.CONTINUE;
87
}
88
89
@Override
90
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
91
Files.copy(file, destDir.resolve(srcDir.relativize(file)));
92
return FileVisitResult.CONTINUE;
93
}
94
});
95
}
96
}
97
98