author | mchung |
Tue, 06 Nov 2018 10:01:16 -0800 | |
changeset 52427 | 3c6aa484536c |
parent 52102 | 19f6b12df31a |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
48841 | 2 |
* Copyright (c) 2016, 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.lang.module.ModuleDescriptor; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
25 |
import java.lang.module.ModuleDescriptor.*; |
36511 | 26 |
import java.lang.module.ModuleFinder; |
27 |
import java.lang.module.ModuleReference; |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
28 |
import java.io.IOException; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
29 |
import java.io.UncheckedIOException; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
30 |
import java.nio.file.Files; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
31 |
import java.nio.file.Path; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
32 |
import java.nio.file.Paths; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
33 |
import java.util.List; |
36511 | 34 |
import java.util.Map; |
35 |
import java.util.Set; |
|
36 |
||
52427
3c6aa484536c
8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents:
52102
diff
changeset
|
37 |
import jdk.internal.access.JavaLangModuleAccess; |
3c6aa484536c
8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents:
52102
diff
changeset
|
38 |
import jdk.internal.access.SharedSecrets; |
36511 | 39 |
import org.testng.annotations.Test; |
40 |
import static org.testng.Assert.*; |
|
41 |
||
42 |
/** |
|
43 |
* @test |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
44 |
* @bug 8142968 8173381 |
52427
3c6aa484536c
8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents:
52102
diff
changeset
|
45 |
* @modules java.base/jdk.internal.access |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
46 |
* @modules java.base/jdk.internal.module |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
47 |
* @modules java.base/jdk.internal.org.objectweb.asm |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
48 |
* @build ModuleTargetHelper |
38766
12239516ceb1
8158194: Rename the directory “InstalledModuleDescriptors” and any reference to “installed” to “system” in the tests
mli
parents:
36511
diff
changeset
|
49 |
* @run testng SystemModulesTest |
36511 | 50 |
* @summary Verify the properties of ModuleDescriptor created |
38766
12239516ceb1
8158194: Rename the directory “InstalledModuleDescriptors” and any reference to “installed” to “system” in the tests
mli
parents:
36511
diff
changeset
|
51 |
* by SystemModules |
36511 | 52 |
*/ |
53 |
||
38766
12239516ceb1
8158194: Rename the directory “InstalledModuleDescriptors” and any reference to “installed” to “system” in the tests
mli
parents:
36511
diff
changeset
|
54 |
public class SystemModulesTest { |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
55 |
private static final JavaLangModuleAccess JLMA = |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
56 |
SharedSecrets.getJavaLangModuleAccess(); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
57 |
private static final String OS_NAME = System.getProperty("os.name"); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
58 |
private static final String OS_ARCH = System.getProperty("os.arch"); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
59 |
// system modules containing no package |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
60 |
private static final Set<String> EMPTY_MODULES = |
48841 | 61 |
Set.of("java.se", "jdk.jdwp.agent", "jdk.pack"); |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
62 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
63 |
@Test |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
64 |
public void testSystemModules() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
65 |
Path jimage = Paths.get(System.getProperty("java.home"), "lib", "modules"); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
66 |
if (Files.notExists(jimage)) |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
67 |
return; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
68 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
69 |
ModuleFinder.ofSystem().findAll().stream() |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
70 |
.forEach(this::checkAttributes); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
71 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
72 |
|
44761
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
73 |
// JMOD files are created with OS name and arch matching the bundle name |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
74 |
private boolean checkOSName(String name) { |
44761
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
75 |
if (OS_NAME.startsWith("Windows")) { |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
76 |
return name.equals("windows"); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
77 |
} |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
78 |
|
44761
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
79 |
switch (OS_NAME) { |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
80 |
case "Linux": |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
81 |
return name.equals("linux"); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
82 |
case "SunOS": |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
83 |
return name.equals("solaris"); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
84 |
case "Mac OS X": |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
85 |
return name.equals("macos"); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
86 |
default: |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
87 |
// skip validation on unknown platform |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
88 |
System.out.println("Skip checking OS name in ModuleTarget: " + name); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
89 |
return true; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
90 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
91 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
92 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
93 |
private boolean checkOSArch(String name) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
94 |
if (name.equals(OS_ARCH)) |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
95 |
return true; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
96 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
97 |
switch (OS_ARCH) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
98 |
case "i386": |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
99 |
case "x86": |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
100 |
return name.equals("x86"); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
101 |
case "amd64": |
44761
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
102 |
case "x86_64": |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
103 |
return name.equals("amd64"); |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
104 |
default: |
44761
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
105 |
// skip validation on unknown platform |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
106 |
System.out.println("Skip checking OS arch in ModuleTarget: " + name); |
36aae904cea9
8175819: OS name and arch in JMOD files should match the values as in the bundle names
mchung
parents:
44359
diff
changeset
|
107 |
return true; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
108 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
109 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
110 |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
111 |
private void checkAttributes(ModuleReference modRef) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
112 |
try { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
113 |
ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.read(modRef); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
114 |
String[] values = mt.targetPlatform().split("-"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
115 |
assertTrue(checkOSName(values[0])); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
116 |
assertTrue(checkOSArch(values[1])); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
117 |
} catch (IOException exp) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43336
diff
changeset
|
118 |
throw new UncheckedIOException(exp); |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
119 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
120 |
} |
36511 | 121 |
|
122 |
/** |
|
123 |
* Verify ModuleDescriptor contains unmodifiable sets |
|
124 |
*/ |
|
125 |
@Test |
|
126 |
public void testUnmodifableDescriptors() throws Exception { |
|
127 |
ModuleFinder.ofSystem().findAll() |
|
128 |
.stream() |
|
129 |
.map(ModuleReference::descriptor) |
|
130 |
.forEach(this::testModuleDescriptor); |
|
131 |
} |
|
132 |
||
133 |
private void testModuleDescriptor(ModuleDescriptor md) { |
|
134 |
assertUnmodifiable(md.packages(), "package"); |
|
135 |
assertUnmodifiable(md.requires(), |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
136 |
JLMA.newRequires(Set.of(Requires.Modifier.TRANSITIVE), |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
137 |
"require", null)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
138 |
for (Requires req : md.requires()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
139 |
assertUnmodifiable(req.modifiers(), Requires.Modifier.TRANSITIVE); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
140 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
141 |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
142 |
assertUnmodifiable(md.exports(), JLMA.newExports(Set.of(), "export", Set.of())); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
143 |
for (Exports exp : md.exports()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
144 |
assertUnmodifiable(exp.modifiers(), Exports.Modifier.SYNTHETIC); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
145 |
assertUnmodifiable(exp.targets(), "target"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
146 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
147 |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
148 |
assertUnmodifiable(md.opens(), JLMA.newOpens(Set.of(), "open", Set.of())); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
149 |
for (Opens opens : md.opens()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
150 |
assertUnmodifiable(opens.modifiers(), Opens.Modifier.SYNTHETIC); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
151 |
assertUnmodifiable(opens.targets(), "target"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
152 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
153 |
|
36511 | 154 |
assertUnmodifiable(md.uses(), "use"); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
155 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
156 |
assertUnmodifiable(md.provides(), |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42703
diff
changeset
|
157 |
JLMA.newProvides("provide", List.of("provide"))); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
158 |
for (Provides provides : md.provides()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
159 |
assertUnmodifiable(provides.providers(), "provide"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
160 |
} |
36511 | 161 |
|
162 |
} |
|
163 |
||
164 |
private <T> void assertUnmodifiable(Set<T> set, T dummy) { |
|
165 |
try { |
|
166 |
set.add(dummy); |
|
167 |
fail("Should throw UnsupportedOperationException"); |
|
168 |
} catch (UnsupportedOperationException e) { |
|
169 |
// pass |
|
170 |
} catch (Exception e) { |
|
171 |
fail("Should throw UnsupportedOperationException"); |
|
172 |
} |
|
173 |
} |
|
174 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
175 |
private <T> void assertUnmodifiable(List<T> list, T dummy) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
176 |
try { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
177 |
list.add(dummy); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
178 |
fail("Should throw UnsupportedOperationException"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
179 |
} catch (UnsupportedOperationException e) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
180 |
// pass |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
181 |
} catch (Exception e) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
182 |
fail("Should throw UnsupportedOperationException"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
183 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
184 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38766
diff
changeset
|
185 |
|
36511 | 186 |
private <T, V> void assertUnmodifiable(Map<T, V> set, T dummyKey, V dummyValue) { |
187 |
try { |
|
188 |
set.put(dummyKey, dummyValue); |
|
189 |
fail("Should throw UnsupportedOperationException"); |
|
190 |
} catch (UnsupportedOperationException e) { |
|
191 |
// pass |
|
192 |
} catch (Exception e) { |
|
193 |
fail("Should throw UnsupportedOperationException"); |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
} |