Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jlink/plugins/ExcludeModuleInfoTest.java
41149 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 8194922
27
* @summary jlink --exclude-resources should never exclude module-info.class
28
* @modules jdk.jlink/jdk.tools.jlink.internal
29
* jdk.jlink/jdk.tools.jlink.internal.plugins
30
* jdk.jlink/jdk.tools.jlink.plugin
31
* @run main ExcludeModuleInfoTest
32
*/
33
34
import java.io.File;
35
import java.nio.file.Files;
36
import java.util.HashMap;
37
import java.util.Map;
38
import jdk.tools.jlink.internal.ResourcePoolManager;
39
40
import jdk.tools.jlink.internal.plugins.ExcludePlugin;
41
import jdk.tools.jlink.plugin.PluginException;
42
import jdk.tools.jlink.plugin.ResourcePool;
43
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
44
import jdk.tools.jlink.plugin.ResourcePoolEntry;
45
46
public class ExcludeModuleInfoTest {
47
48
public static void main(String[] args) throws Exception {
49
new ExcludeModuleInfoTest().test();
50
}
51
52
public void test() throws Exception {
53
check("**.class", "/mymodule/module-info.class");
54
check("/java.base/module-info.class", "/java.base/module-info.class");
55
}
56
57
public void check(String s, String sample) throws Exception {
58
Map<String, String> prop = new HashMap<>();
59
ExcludePlugin excludePlugin = new ExcludePlugin();
60
prop.put(excludePlugin.getName(), s);
61
excludePlugin.configure(prop);
62
ResourcePoolManager resourcesMgr = new ResourcePoolManager();
63
ResourcePoolEntry resource = ResourcePoolEntry.create(sample, new byte[0]);
64
resourcesMgr.add(resource);
65
ResourcePoolManager resultMgr = new ResourcePoolManager();
66
try {
67
excludePlugin.transform(resourcesMgr.resourcePool(),
68
resultMgr.resourcePoolBuilder());
69
throw new AssertionError(sample + " exclusion should have resulted in exception");
70
} catch (PluginException pe) {
71
System.err.println("Got exception as expected: " + pe);
72
pe.printStackTrace();
73
}
74
}
75
}
76
77