author | sundar |
Tue, 20 Feb 2018 15:25:40 +0530 | |
changeset 48917 | 37beaca49e63 |
parent 48663 | b742e0f9ce80 |
child 52848 | 9144c0b5c1e1 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
48663
b742e0f9ce80
8161348: Several tools/jlink tests failed in "-Xcomp" mode due to time out
anazarov
parents:
47464
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
36511 | 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.io.PrintWriter; |
|
26 |
import java.io.StringWriter; |
|
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
27 |
import java.lang.module.ModuleDescriptor; |
36511 | 28 |
import java.nio.file.Files; |
29 |
import java.nio.file.Path; |
|
30 |
import java.nio.file.Paths; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Collections; |
|
33 |
import java.util.List; |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
34 |
import java.util.spi.ToolProvider; |
36511 | 35 |
import java.util.stream.Stream; |
36 |
||
37 |
import jdk.tools.jlink.plugin.Plugin; |
|
38 |
import jdk.tools.jlink.internal.PluginRepository; |
|
39 |
import tests.Helper; |
|
40 |
import tests.JImageGenerator; |
|
41 |
||
42 |
/* |
|
43 |
* @test |
|
44 |
* @summary Test image creation |
|
47464
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
45 |
* @bug 8189777 |
48917
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
46 |
* @bug 8194922 |
36511 | 47 |
* @author Jean-Francois Denise |
48663
b742e0f9ce80
8161348: Several tools/jlink tests failed in "-Xcomp" mode due to time out
anazarov
parents:
47464
diff
changeset
|
48 |
* @requires (vm.compMode != "Xcomp" & os.maxMemory >= 2g) |
36511 | 49 |
* @library ../lib |
50 |
* @modules java.base/jdk.internal.jimage |
|
51 |
* jdk.jdeps/com.sun.tools.classfile |
|
52 |
* jdk.jlink/jdk.tools.jlink.internal |
|
43185 | 53 |
* jdk.jlink/jdk.tools.jlink.plugin |
36511 | 54 |
* jdk.jlink/jdk.tools.jimage |
55 |
* jdk.compiler |
|
56 |
* @build tests.* |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
57 |
* @run main/othervm -Xmx1g JLinkTest |
36511 | 58 |
*/ |
59 |
public class JLinkTest { |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
60 |
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
61 |
.orElseThrow(() -> |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
62 |
new RuntimeException("jlink tool not found") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
63 |
); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
64 |
|
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
65 |
// number of built-in plugins from jdk.jlink module |
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
66 |
private static int getNumJlinkPlugins() { |
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
67 |
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor(); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
68 |
return desc.provides().stream() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
69 |
.filter(p -> p.service().equals(Plugin.class.getName())) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
70 |
.map(p -> p.providers().size()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
71 |
.findAny() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
72 |
.orElse(0); |
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
73 |
} |
36511 | 74 |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
75 |
private static boolean isOfJLinkModule(Plugin p) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
76 |
return p.getClass().getModule() == Plugin.class.getModule(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
77 |
} |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
78 |
|
36511 | 79 |
public static void main(String[] args) throws Exception { |
80 |
||
81 |
Helper helper = Helper.newHelper(); |
|
82 |
if (helper == null) { |
|
83 |
System.err.println("Test not run"); |
|
84 |
return; |
|
85 |
} |
|
86 |
helper.generateDefaultModules(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
87 |
// expected num. of plugins from jdk.jlink module |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
88 |
int expectedJLinkPlugins = getNumJlinkPlugins(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
89 |
int totalPlugins = 0; |
36511 | 90 |
{ |
91 |
// number of built-in plugins |
|
92 |
List<Plugin> builtInPlugins = new ArrayList<>(); |
|
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44367
diff
changeset
|
93 |
builtInPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot())); |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
94 |
totalPlugins = builtInPlugins.size(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
95 |
// actual num. of plugins loaded from jdk.jlink module |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
96 |
int actualJLinkPlugins = 0; |
36511 | 97 |
for (Plugin p : builtInPlugins) { |
98 |
p.getState(); |
|
99 |
p.getType(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
100 |
if (isOfJLinkModule(p)) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
101 |
actualJLinkPlugins++; |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
102 |
} |
36511 | 103 |
} |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
104 |
if (expectedJLinkPlugins != actualJLinkPlugins) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
105 |
throw new AssertionError("Actual plugins loaded from jdk.jlink: " + |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
106 |
actualJLinkPlugins + " which doesn't match expected number : " + |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
107 |
expectedJLinkPlugins); |
36511 | 108 |
} |
109 |
} |
|
110 |
||
111 |
{ |
|
47464
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
112 |
// No --module-path specified. $JAVA_HOME/jmods should be assumed. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
113 |
// The following should succeed as it uses only system modules. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
114 |
String imageDir = "bug818977-no-modulepath"; |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
115 |
JImageGenerator.getJLinkTask() |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
116 |
.output(helper.createNewImageDir(imageDir)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
117 |
.addMods("jdk.scripting.nashorn") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
118 |
.call().assertSuccess(); |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
119 |
} |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
120 |
|
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
121 |
{ |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
122 |
// invalid --module-path specified. java.base not found it it. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
123 |
// $JAVA_HOME/jmods should be added automatically. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
124 |
// The following should succeed as it uses only system modules. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
125 |
String imageDir = "bug8189777-invalid-modulepath"; |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
126 |
JImageGenerator.getJLinkTask() |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
127 |
.modulePath("does_not_exist_path") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
128 |
.output(helper.createNewImageDir(imageDir)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
129 |
.addMods("jdk.scripting.nashorn") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
130 |
.call().assertSuccess(); |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
131 |
} |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
132 |
|
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
133 |
{ |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
134 |
// No --module-path specified. --add-modules ALL-MODULE-PATH specified. |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
135 |
String imageDir = "bug8189777-all-module-path"; |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
136 |
JImageGenerator.getJLinkTask() |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
137 |
.output(helper.createNewImageDir(imageDir)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
138 |
.addMods("ALL-MODULE-PATH") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
139 |
.call().assertSuccess(); |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
140 |
} |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
141 |
|
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
142 |
{ |
36511 | 143 |
String moduleName = "bug8134651"; |
144 |
JImageGenerator.getJLinkTask() |
|
145 |
.modulePath(helper.defaultModulePath()) |
|
146 |
.output(helper.createNewImageDir(moduleName)) |
|
147 |
.addMods("leaf1") |
|
148 |
.call().assertSuccess(); |
|
149 |
JImageGenerator.getJLinkTask() |
|
150 |
.modulePath(helper.defaultModulePath()) |
|
151 |
.addMods("leaf1") |
|
152 |
.option("--output") |
|
153 |
.call().assertFailure("Error: no value given for --output"); |
|
154 |
JImageGenerator.getJLinkTask() |
|
155 |
.modulePath("") |
|
156 |
.output(helper.createNewImageDir(moduleName)) |
|
157 |
.addMods("leaf1") |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
40209
diff
changeset
|
158 |
.call().assertFailure("Error: no value given for --module-path"); |
47464
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
159 |
// do not include standard module path - should be added automatically |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
160 |
JImageGenerator.getJLinkTask() |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
161 |
.modulePath(helper.defaultModulePath(false)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
162 |
.output(helper.createNewImageDir(moduleName)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
163 |
.addMods("leaf1") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
164 |
.call().assertSuccess(); |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
165 |
// no --module-path. default sys mod path is assumed - but that won't contain 'leaf1' module |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
166 |
JImageGenerator.getJLinkTask() |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
167 |
.output(helper.createNewImageDir(moduleName)) |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
168 |
.addMods("leaf1") |
36de9c637393
8189777: jlink --module-path default value and automatic addition of $JAVA_HOME/jmods if java.base is missing
sundar
parents:
47216
diff
changeset
|
169 |
.call().assertFailure("Error: Module leaf1 not found"); |
36511 | 170 |
} |
171 |
||
172 |
{ |
|
40209
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
173 |
String moduleName = "m"; // 8163382 |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
174 |
Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
175 |
JImageGenerator.getJLinkTask() |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
176 |
.modulePath(helper.defaultModulePath()) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
177 |
.output(helper.createNewImageDir(moduleName)) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
178 |
.addMods("m") |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
179 |
.call().assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
180 |
moduleName = "mod"; |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
181 |
jmod = helper.generateDefaultJModule(moduleName).assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
182 |
JImageGenerator.getJLinkTask() |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
183 |
.modulePath(helper.defaultModulePath()) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
184 |
.output(helper.createNewImageDir(moduleName)) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
185 |
.addMods("m") |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
186 |
.call().assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
187 |
} |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
188 |
|
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
189 |
{ |
41212
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
190 |
String moduleName = "m_8165735"; // JDK-8165735 |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
191 |
helper.generateDefaultJModule(moduleName+"dependency").assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
192 |
Path jmod = helper.generateDefaultJModule(moduleName, moduleName+"dependency").assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
193 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
194 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
195 |
.repeatedModulePath(".") // second --module-path overrides the first one |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
196 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
197 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
198 |
// second --module-path does not have that module |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
199 |
.call().assertFailure("Error: Module m_8165735 not found"); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
200 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
201 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
202 |
.modulePath(".") // first --module-path overridden later |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
203 |
.repeatedModulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
204 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
205 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
206 |
// second --module-path has that module |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
207 |
.call().assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
208 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
209 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
210 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
211 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
212 |
.limitMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
213 |
.repeatedLimitMods("java.base") // second --limit-modules overrides first |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
214 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
215 |
.call().assertFailure("Error: Module m_8165735dependency not found, required by m_8165735"); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
216 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
217 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
218 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
219 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
220 |
.limitMods("java.base") |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
221 |
.repeatedLimitMods(moduleName) // second --limit-modules overrides first |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
222 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
223 |
.call().assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
224 |
} |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
225 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
226 |
{ |
36511 | 227 |
// Help |
228 |
StringWriter writer = new StringWriter(); |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
229 |
PrintWriter pw = new PrintWriter(writer); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
230 |
JLINK_TOOL.run(pw, pw, "--help"); |
36511 | 231 |
String output = writer.toString(); |
232 |
if (output.split("\n").length < 10) { |
|
233 |
System.err.println(output); |
|
234 |
throw new AssertionError("Help"); |
|
235 |
} |
|
236 |
} |
|
237 |
||
238 |
{ |
|
239 |
// List plugins |
|
240 |
StringWriter writer = new StringWriter(); |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
241 |
PrintWriter pw = new PrintWriter(writer); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
242 |
|
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
243 |
JLINK_TOOL.run(pw, pw, "--list-plugins"); |
36511 | 244 |
String output = writer.toString(); |
245 |
long number = Stream.of(output.split("\\R")) |
|
246 |
.filter((s) -> s.matches("Plugin Name:.*")) |
|
247 |
.count(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
248 |
if (number != totalPlugins) { |
36511 | 249 |
System.err.println(output); |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
250 |
throw new AssertionError("Found: " + number + " expected " + totalPlugins); |
36511 | 251 |
} |
252 |
} |
|
253 |
||
254 |
// filter out files and resources + Skip debug + compress |
|
255 |
{ |
|
256 |
String[] userOptions = {"--compress", "2", "--strip-debug", |
|
257 |
"--exclude-resources", "*.jcov, */META-INF/*", "--exclude-files", |
|
258 |
"*" + Helper.getDebugSymbolsExtension()}; |
|
259 |
String moduleName = "excludezipskipdebugcomposite2"; |
|
260 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
261 |
String[] res = {".jcov", "/META-INF/"}; |
|
262 |
String[] files = {Helper.getDebugSymbolsExtension()}; |
|
263 |
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); |
|
264 |
helper.checkImage(imageDir, moduleName, res, files); |
|
265 |
} |
|
266 |
||
267 |
// filter out + Skip debug + compress with filter + sort resources |
|
268 |
{ |
|
269 |
String[] userOptions2 = {"--compress=2:compress-filter=^/java.base/*", |
|
270 |
"--strip-debug", "--exclude-resources", |
|
37893
f1cc7d17e66b
8156781: change to jlink has result in test failure
jlaskey
parents:
37779
diff
changeset
|
271 |
"*.jcov, */META-INF/*", "--order-resources", |
36511 | 272 |
"*/module-info.class,/sortcomposite2/*,*/javax/management/*"}; |
273 |
String moduleName = "excludezipfilterskipdebugcomposite2"; |
|
274 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
275 |
String[] res = {".jcov", "/META-INF/"}; |
|
276 |
Path imageDir = helper.generateDefaultImage(userOptions2, moduleName).assertSuccess(); |
|
277 |
helper.checkImage(imageDir, moduleName, res, null); |
|
278 |
} |
|
279 |
||
48917
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
280 |
// module-info.class should not be excluded |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
281 |
{ |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
282 |
String[] userOptions = { "--exclude-resources", "/jdk_8194922/module-info.class" }; |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
283 |
String moduleName = "jdk_8194922"; |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
284 |
helper.generateDefaultJModule(moduleName); |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
285 |
helper.generateDefaultImage(userOptions, moduleName). |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
286 |
assertFailure("Cannot exclude /jdk_8194922/module-info.class"); |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
287 |
} |
37beaca49e63
8194922: jlink --exclude-resources should never exclude module-info.class
sundar
parents:
48663
diff
changeset
|
288 |
|
36511 | 289 |
// default compress |
290 |
{ |
|
291 |
testCompress(helper, "compresscmdcomposite2", "--compress", "2"); |
|
292 |
} |
|
293 |
||
294 |
{ |
|
295 |
testCompress(helper, "compressfiltercmdcomposite2", |
|
296 |
"--compress=2:filter=^/java.base/java/lang/*"); |
|
297 |
} |
|
298 |
||
299 |
// compress 0 |
|
300 |
{ |
|
301 |
testCompress(helper, "compress0filtercmdcomposite2", |
|
302 |
"--compress=0:filter=^/java.base/java/lang/*"); |
|
303 |
} |
|
304 |
||
305 |
// compress 1 |
|
306 |
{ |
|
307 |
testCompress(helper, "compress1filtercmdcomposite2", |
|
308 |
"--compress=1:filter=^/java.base/java/lang/*"); |
|
309 |
} |
|
310 |
||
311 |
// compress 2 |
|
312 |
{ |
|
313 |
testCompress(helper, "compress2filtercmdcomposite2", |
|
314 |
"--compress=2:filter=^/java.base/java/lang/*"); |
|
315 |
} |
|
316 |
||
317 |
// invalid compress level |
|
318 |
{ |
|
319 |
String[] userOptions = {"--compress", "invalid"}; |
|
320 |
String moduleName = "invalidCompressLevel"; |
|
321 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36757
diff
changeset
|
322 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid"); |
36511 | 323 |
} |
324 |
||
41766 | 325 |
// orphan argument - JDK-8166810 |
36511 | 326 |
{ |
41766 | 327 |
String[] userOptions = {"--compress", "2", "foo" }; |
328 |
String moduleName = "orphanarg1"; |
|
36511 | 329 |
helper.generateDefaultJModule(moduleName, "composite2"); |
44367
a81c9c6619fb
8174826: jlink support for linking in service provider modules
mchung
parents:
43495
diff
changeset
|
330 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: foo"); |
36511 | 331 |
} |
332 |
||
41766 | 333 |
// orphan argument - JDK-8166810 |
334 |
{ |
|
335 |
String[] userOptions = {"--output", "foo", "bar" }; |
|
336 |
String moduleName = "orphanarg2"; |
|
337 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
44367
a81c9c6619fb
8174826: jlink support for linking in service provider modules
mchung
parents:
43495
diff
changeset
|
338 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: bar"); |
41766 | 339 |
} |
43495
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
340 |
|
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
341 |
// basic check for --help - JDK-8173717 |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
342 |
{ |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
343 |
JImageGenerator.getJLinkTask() |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
344 |
.option("--help") |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
345 |
.call().assertSuccess(); |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
346 |
} |
36511 | 347 |
} |
348 |
||
349 |
private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException { |
|
350 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
351 |
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); |
|
352 |
helper.checkImage(imageDir, moduleName, null, null); |
|
353 |
} |
|
354 |
} |