Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jlink/JLinkPluginsTest.java
41144 views
1
/*
2
* Copyright (c) 2015, 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
import java.io.IOException;
25
import java.nio.file.Files;
26
import java.nio.file.Path;
27
import java.nio.file.Paths;
28
import java.util.Collections;
29
30
import tests.Helper;
31
32
/*
33
* @test
34
* @summary Test image creation
35
* @author Jean-Francois Denise
36
* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g)
37
* @library ../lib
38
* @modules java.base/jdk.internal.jimage
39
* jdk.jdeps/com.sun.tools.classfile
40
* jdk.jlink/jdk.tools.jlink.internal
41
* jdk.jlink/jdk.tools.jmod
42
* jdk.jlink/jdk.tools.jimage
43
* jdk.compiler
44
* @build tests.*
45
* @run main/othervm -verbose:gc -Xmx1g JLinkPluginsTest
46
*/
47
public class JLinkPluginsTest {
48
49
private static String createProperties(String fileName, String content) throws IOException {
50
Path p = Paths.get(fileName);
51
Files.write(p, Collections.singletonList(content));
52
return p.toAbsolutePath().toString();
53
}
54
55
public static void main(String[] args) throws Exception {
56
Helper helper = Helper.newHelper();
57
if (helper == null) {
58
System.err.println("Test not run");
59
return;
60
}
61
helper.generateDefaultModules();
62
{
63
// Skip debug
64
String[] userOptions = {"--strip-debug"};
65
String moduleName = "skipdebugcomposite";
66
helper.generateDefaultJModule(moduleName, "composite2");
67
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
68
helper.checkImage(imageDir, moduleName, null, null);
69
}
70
{
71
// Filter out files
72
String[] userOptions = {"--exclude-resources", "*.jcov, */META-INF/*"};
73
String moduleName = "excludecomposite";
74
helper.generateDefaultJModule(moduleName, "composite2");
75
String[] res = {".jcov", "/META-INF/"};
76
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
77
helper.checkImage(imageDir, moduleName, res, null);
78
}
79
{
80
// disable generate jli classes - JDK-8160063
81
String[] userOptions = {"--disable-plugin", "generate-jli-classes"};
82
String moduleName = "jlidisabled";
83
helper.generateDefaultJModule(moduleName, "composite2");
84
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
85
helper.checkImage(imageDir, moduleName, null, null);
86
}
87
{
88
// disable invalid plugin - JDK-8160063
89
String[] userOptions = {"--disable-plugin", "non-existent-plugin"};
90
String moduleName = "invaliddisabled";
91
helper.generateDefaultJModule(moduleName, "composite2");
92
helper.generateDefaultImage(userOptions, moduleName).
93
assertFailure("Error: No such plugin: non-existent-plugin");
94
}
95
}
96
}
97
98