1 /**
2 * Copyright (c) 2015, 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 */
220 Set<String> jmods = Set.of("m1", "m2", "m3");
221
222 // create JMOD and JAR files
223 jars.forEach(ht::makeJar);
224 jmods.forEach(ht::makeJmod);
225
226 // run jmod hash command
227 runJmod(List.of("hash", "--module-path", ht.lib.toString(),
228 "--hash-modules", "^j.*|^m.*"));
229
230 /*
231 * j1 and j2 are the modules with hashes recorded.
232 */
233 ht.checkHashes("j2", "j3");
234 ht.checkHashes("j1", "m1", "m2", "m3", "j3");
235 Stream.concat(jars.stream(), jmods.stream())
236 .filter(mn -> !mn.equals("j1") && !mn.equals("j2"))
237 .forEach(mn -> assertTrue(ht.hashes(mn) == null));
238 }
239
240 @Test
241 public static void upgradeableModule() throws IOException {
242 Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
243 if (!Files.exists(mpath)) {
244 return;
245 }
246
247 Path dest = Paths.get("test4");
248 HashesTest ht = new HashesTest(dest);
249 ht.makeModule("m1");
250 ht.makeModule("java.xml.bind", "m1");
251 ht.makeModule("java.xml.ws", "java.xml.bind");
252 ht.makeModule("m2", "java.xml.ws");
253
254 ht.makeJmod("m1");
255 ht.makeJmod("m2");
256 ht.makeJmod("java.xml.ws");
257 ht.makeJmod("java.xml.bind",
258 "--module-path",
259 ht.lib.toString() + File.pathSeparator + mpath,
260 "--hash-modules", "^java.xml.*|^m.*");
261
262 ht.checkHashes("java.xml.bind", "java.xml.ws", "m2");
263 }
264
265 @Test
266 public static void testImageJmods() throws IOException {
267 Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
268 if (!Files.exists(mpath)) {
269 return;
270 }
271
272 Path dest = Paths.get("test5");
273 HashesTest ht = new HashesTest(dest);
274 ht.makeModule("m1", "jdk.compiler", "jdk.attach");
275 ht.makeModule("m2", "m1");
276 ht.makeModule("m3", "java.compiler");
277
278 ht.makeJmod("m1");
279 ht.makeJmod("m2");
280
281 runJmod(List.of("hash",
282 "--module-path",
283 mpath.toString() + File.pathSeparator + ht.lib.toString(),
|
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 */
220 Set<String> jmods = Set.of("m1", "m2", "m3");
221
222 // create JMOD and JAR files
223 jars.forEach(ht::makeJar);
224 jmods.forEach(ht::makeJmod);
225
226 // run jmod hash command
227 runJmod(List.of("hash", "--module-path", ht.lib.toString(),
228 "--hash-modules", "^j.*|^m.*"));
229
230 /*
231 * j1 and j2 are the modules with hashes recorded.
232 */
233 ht.checkHashes("j2", "j3");
234 ht.checkHashes("j1", "m1", "m2", "m3", "j3");
235 Stream.concat(jars.stream(), jmods.stream())
236 .filter(mn -> !mn.equals("j1") && !mn.equals("j2"))
237 .forEach(mn -> assertTrue(ht.hashes(mn) == null));
238 }
239
240
241 @Test
242 public static void testImageJmods() throws IOException {
243 Path mpath = Paths.get(System.getProperty("java.home"), "jmods");
244 if (!Files.exists(mpath)) {
245 return;
246 }
247
248 Path dest = Paths.get("test5");
249 HashesTest ht = new HashesTest(dest);
250 ht.makeModule("m1", "jdk.compiler", "jdk.attach");
251 ht.makeModule("m2", "m1");
252 ht.makeModule("m3", "java.compiler");
253
254 ht.makeJmod("m1");
255 ht.makeJmod("m2");
256
257 runJmod(List.of("hash",
258 "--module-path",
259 mpath.toString() + File.pathSeparator + ht.lib.toString(),
|