author | alanb |
Thu, 01 Dec 2016 08:57:53 +0000 | |
changeset 42338 | a60f280f803c |
parent 38766 | 12239516ceb1 |
child 43336 | be9fca030f91 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
2 |
* Copyright (c) 2016, 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 |
package p1; |
|
25 |
||
26 |
import java.lang.module.ModuleDescriptor; |
|
27 |
import java.net.URI; |
|
28 |
import java.nio.file.FileSystem; |
|
29 |
import java.nio.file.FileSystems; |
|
30 |
import java.nio.file.Files; |
|
31 |
import java.nio.file.Path; |
|
37536
dcd80bbbb686
8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms
sherman
parents:
36511
diff
changeset
|
32 |
import java.util.Collections; |
36511 | 33 |
import java.util.Set; |
34 |
||
35 |
public class Main { |
|
36 |
public static void main(String... args) throws Exception { |
|
37 |
// load another package |
|
38 |
p2.T.test(); |
|
39 |
||
38766
12239516ceb1
8158194: Rename the directory “InstalledModuleDescriptors” and any reference to “installed” to “system” in the tests
mli
parents:
37536
diff
changeset
|
40 |
// check the module descriptor of a system module |
36511 | 41 |
validate(Main.class.getModule().getDescriptor()); |
42 |
||
43 |
// read m1/module-info.class |
|
37536
dcd80bbbb686
8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms
sherman
parents:
36511
diff
changeset
|
44 |
FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), |
dcd80bbbb686
8154498: fix to 8154403 results in failure of UserModuleTest.java on all platforms
sherman
parents:
36511
diff
changeset
|
45 |
Collections.emptyMap()); |
36511 | 46 |
Path path = fs.getPath("/", "modules", "m1", "module-info.class"); |
47 |
validate(ModuleDescriptor.read(Files.newInputStream(path))); |
|
48 |
} |
|
49 |
||
50 |
static void validate(ModuleDescriptor md) { |
|
51 |
checkPackages(md.packages(), "p1", "p2"); |
|
52 |
} |
|
53 |
||
54 |
static void checkPackages(Set<String> pkgs, String... expected) { |
|
55 |
for (String pn : expected) { |
|
56 |
if (!pkgs.contains(pn)) { |
|
57 |
throw new RuntimeException(pn + " missing in " + pkgs); |
|
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
} |