author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 47004 | jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java@b7e72fc752c9 |
child 47866 | 39db80b32b69 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2 |
* Copyright (c) 2009, 2017, 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package java.lang.module; |
|
27 |
||
28 |
import java.io.InputStream; |
|
29 |
import java.io.IOException; |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
30 |
import java.io.PrintStream; |
36511 | 31 |
import java.io.UncheckedIOException; |
32 |
import java.nio.ByteBuffer; |
|
41817
b90ad1de93ea
8168789: ModuleReader.list and ModuleFinder.of update
alanb
parents:
39050
diff
changeset
|
33 |
import java.nio.file.Path; |
36511 | 34 |
import java.util.ArrayList; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
35 |
import java.util.Arrays; |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
36 |
import java.util.Collection; |
36511 | 37 |
import java.util.Collections; |
38 |
import java.util.EnumSet; |
|
39 |
import java.util.HashMap; |
|
40 |
import java.util.HashSet; |
|
41 |
import java.util.List; |
|
42 |
import java.util.Map; |
|
43 |
import java.util.Objects; |
|
44 |
import java.util.Optional; |
|
45 |
import java.util.Set; |
|
46 |
import java.util.function.Supplier; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
47 |
import java.util.stream.Collectors; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
48 |
import java.util.stream.Stream; |
36511 | 49 |
|
50 |
import static jdk.internal.module.Checks.*; |
|
51 |
import static java.util.Objects.*; |
|
52 |
||
53 |
import jdk.internal.module.Checks; |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
54 |
import jdk.internal.module.ModuleInfo; |
36511 | 55 |
|
56 |
||
57 |
/** |
|
58 |
* A module descriptor. |
|
59 |
* |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
60 |
* <p> A module descriptor describes a named module and defines methods to |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
61 |
* obtain each of its components. The module descriptor for a named module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
62 |
* in the Java virtual machine is obtained by invoking the {@link |
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
63 |
* java.lang.Module Module}'s {@link java.lang.Module#getDescriptor |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
64 |
* getDescriptor} method. Module descriptors can also be created using the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
65 |
* {@link ModuleDescriptor.Builder} class or by reading the binary form of a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
66 |
* module declaration ({@code module-info.class}) using the {@link |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
67 |
* #read(InputStream,Supplier) read} methods defined here. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
68 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
69 |
* <p> A module descriptor describes a <em>normal</em>, open, or automatic |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
70 |
* module. <em>Normal</em> modules and open modules describe their {@link |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
71 |
* #requires() dependences}, {@link #exports() exported-packages}, the services |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
72 |
* that they {@link #uses() use} or {@link #provides() provide}, and other |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
73 |
* components. <em>Normal</em> modules may {@link #opens() open} specific |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
74 |
* packages. The module descriptor for an open modules does not declare any |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
75 |
* open packages (its {@code opens} method returns an empty set) but when |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
76 |
* instantiated in the Java virtual machine then it is treated as if all |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
77 |
* packages are open. The module descriptor for an automatic module does not |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
78 |
* declare any dependences (except for the mandatory dependency on {@code |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
79 |
* java.base}), and does not declare any exported or open packages. Automatic |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
80 |
* module receive special treatment during resolution so that they read all |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
81 |
* other modules in the configuration. When an automatic module is instantiated |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
82 |
* in the Java virtual machine then it reads every unnamed module and is |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
83 |
* treated as if all packages are exported and open. </p> |
36511 | 84 |
* |
85 |
* <p> {@code ModuleDescriptor} objects are immutable and safe for use by |
|
86 |
* multiple concurrent threads.</p> |
|
87 |
* |
|
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
88 |
* @see java.lang.Module |
36511 | 89 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
90 |
* @spec JPMS |
36511 | 91 |
*/ |
92 |
||
93 |
public class ModuleDescriptor |
|
94 |
implements Comparable<ModuleDescriptor> |
|
95 |
{ |
|
96 |
||
97 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
98 |
* A modifier on a module. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
99 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
100 |
* @see ModuleDescriptor#modifiers() |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
101 |
* @since 9 |
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44545
diff
changeset
|
102 |
* @spec JPMS |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
103 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
104 |
public static enum Modifier { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
105 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
106 |
* An open module. An open module does not declare any open packages |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
107 |
* but the resulting module is treated as if all packages are open. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
108 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
109 |
OPEN, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
110 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
111 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
112 |
* An automatic module. An automatic module is treated as if it exports |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
113 |
* and opens all packages. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
114 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
115 |
* @apiNote This modifier does not correspond to a module flag in the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
116 |
* binary form of a module declaration ({@code module-info.class}). |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
117 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
118 |
AUTOMATIC, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
119 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
120 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
121 |
* The module was not explicitly or implicitly declared. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
122 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
123 |
SYNTHETIC, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
124 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
125 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
126 |
* The module was implicitly declared. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
127 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
128 |
MANDATED; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
129 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
130 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
131 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
132 |
/** |
36511 | 133 |
* <p> A dependence upon a module </p> |
134 |
* |
|
135 |
* @see ModuleDescriptor#requires() |
|
136 |
* @since 9 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
137 |
* @spec JPMS |
36511 | 138 |
*/ |
139 |
||
140 |
public final static class Requires |
|
141 |
implements Comparable<Requires> |
|
142 |
{ |
|
143 |
||
144 |
/** |
|
145 |
* A modifier on a module dependence. |
|
146 |
* |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
147 |
* @see Requires#modifiers() |
36511 | 148 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
149 |
* @spec JPMS |
36511 | 150 |
*/ |
151 |
public static enum Modifier { |
|
152 |
||
153 |
/** |
|
154 |
* The dependence causes any module which depends on the <i>current |
|
155 |
* module</i> to have an implicitly declared dependence on the module |
|
156 |
* named by the {@code Requires}. |
|
157 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
158 |
TRANSITIVE, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
159 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
160 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
161 |
* The dependence is mandatory in the static phase, during compilation, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
162 |
* but is optional in the dynamic phase, during execution. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
163 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
164 |
STATIC, |
36511 | 165 |
|
166 |
/** |
|
167 |
* The dependence was not explicitly or implicitly declared in the |
|
168 |
* source of the module declaration. |
|
169 |
*/ |
|
170 |
SYNTHETIC, |
|
171 |
||
172 |
/** |
|
173 |
* The dependence was implicitly declared in the source of the module |
|
174 |
* declaration. |
|
175 |
*/ |
|
176 |
MANDATED; |
|
177 |
||
178 |
} |
|
179 |
||
180 |
private final Set<Modifier> mods; |
|
181 |
private final String name; |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
182 |
private final Version compiledVersion; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
183 |
private final String rawCompiledVersion; |
36511 | 184 |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
185 |
private Requires(Set<Modifier> ms, String mn, Version v, String vs) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
186 |
assert v == null || vs == null; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
187 |
if (ms.isEmpty()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
188 |
ms = Collections.emptySet(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
189 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
190 |
ms = Collections.unmodifiableSet(EnumSet.copyOf(ms)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
191 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
192 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
193 |
this.name = mn; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
194 |
this.compiledVersion = v; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
195 |
this.rawCompiledVersion = vs; |
36511 | 196 |
} |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
197 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
198 |
private Requires(Set<Modifier> ms, String mn, Version v, boolean unused) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
199 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
200 |
this.name = mn; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
201 |
this.compiledVersion = v; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
202 |
this.rawCompiledVersion = null; |
36511 | 203 |
} |
204 |
||
205 |
/** |
|
206 |
* Returns the set of modifiers. |
|
207 |
* |
|
208 |
* @return A possibly-empty unmodifiable set of modifiers |
|
209 |
*/ |
|
210 |
public Set<Modifier> modifiers() { |
|
211 |
return mods; |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Return the module name. |
|
216 |
* |
|
217 |
* @return The module name |
|
218 |
*/ |
|
219 |
public String name() { |
|
220 |
return name; |
|
221 |
} |
|
222 |
||
223 |
/** |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
224 |
* Returns the version of the module if recorded at compile-time. |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
225 |
* |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
226 |
* @return The version of the module if recorded at compile-time, |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
227 |
* or an empty {@code Optional} if no version was recorded or |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
228 |
* the version string recorded is {@linkplain Version#parse(String) |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
229 |
* unparseable} |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
230 |
*/ |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
231 |
public Optional<Version> compiledVersion() { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
232 |
return Optional.ofNullable(compiledVersion); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
233 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
234 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
235 |
/** |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
236 |
* Returns the string with the possibly-unparseable version of the module |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
237 |
* if recorded at compile-time. |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
238 |
* |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
239 |
* @return The string containing the version of the module if recorded |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
240 |
* at compile-time, or an empty {@code Optional} if no version |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
241 |
* was recorded |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
242 |
* |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
243 |
* @see #compiledVersion() |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
244 |
*/ |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
245 |
public Optional<String> rawCompiledVersion() { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
246 |
if (compiledVersion != null) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
247 |
return Optional.of(compiledVersion.toString()); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
248 |
} else { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
249 |
return Optional.ofNullable(rawCompiledVersion); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
250 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
251 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
252 |
|
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
253 |
/** |
36511 | 254 |
* Compares this module dependence to another. |
255 |
* |
|
256 |
* <p> Two {@code Requires} objects are compared by comparing their |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
257 |
* module names lexicographically. Where the module names are equal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
258 |
* then the sets of modifiers are compared in the same way that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
259 |
* module modifiers are compared (see {@link ModuleDescriptor#compareTo |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
260 |
* ModuleDescriptor.compareTo}). Where the module names are equal and |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
261 |
* the set of modifiers are equal then the version of the modules |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
262 |
* recorded at compile-time are compared. When comparing the versions |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
263 |
* recorded at compile-time then a dependence that has a recorded |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
264 |
* version is considered to succeed a dependence that does not have a |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
265 |
* recorded version. If both recorded versions are {@linkplain |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
266 |
* Version#parse(String) unparseable} then the {@linkplain |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
267 |
* #rawCompiledVersion() raw version strings} are compared |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
268 |
* lexicographically. </p> |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
269 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
270 |
* @param that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
271 |
* The module dependence to compare |
36511 | 272 |
* |
273 |
* @return A negative integer, zero, or a positive integer if this module |
|
274 |
* dependence is less than, equal to, or greater than the given |
|
275 |
* module dependence |
|
276 |
*/ |
|
277 |
@Override |
|
278 |
public int compareTo(Requires that) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
279 |
if (this == that) return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
280 |
|
36511 | 281 |
int c = this.name().compareTo(that.name()); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
282 |
if (c != 0) return c; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
283 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
284 |
// modifiers |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
285 |
long v1 = modsValue(this.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
286 |
long v2 = modsValue(that.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
287 |
c = Long.compare(v1, v2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
288 |
if (c != 0) return c; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
289 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
290 |
// compiledVersion |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
291 |
c = compare(this.compiledVersion, that.compiledVersion); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
292 |
if (c != 0) return c; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
293 |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
294 |
// rawCompiledVersion |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
295 |
c = compare(this.rawCompiledVersion, that.rawCompiledVersion); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
296 |
if (c != 0) return c; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
297 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
298 |
return 0; |
36511 | 299 |
} |
300 |
||
301 |
/** |
|
302 |
* Tests this module dependence for equality with the given object. |
|
303 |
* |
|
304 |
* <p> If the given object is not a {@code Requires} then this method |
|
305 |
* returns {@code false}. Two module dependence objects are equal if |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
306 |
* the module names are equal, set of modifiers are equal, and the |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
307 |
* compiled version of both modules is equal or not recorded for |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
308 |
* both modules. </p> |
36511 | 309 |
* |
310 |
* <p> This method satisfies the general contract of the {@link |
|
311 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
312 |
* |
|
313 |
* @param ob |
|
314 |
* the object to which this object is to be compared |
|
315 |
* |
|
316 |
* @return {@code true} if, and only if, the given object is a module |
|
317 |
* dependence that is equal to this module dependence |
|
318 |
*/ |
|
319 |
@Override |
|
320 |
public boolean equals(Object ob) { |
|
321 |
if (!(ob instanceof Requires)) |
|
322 |
return false; |
|
323 |
Requires that = (Requires)ob; |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
324 |
return name.equals(that.name) && mods.equals(that.mods) |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
325 |
&& Objects.equals(compiledVersion, that.compiledVersion) |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
326 |
&& Objects.equals(rawCompiledVersion, that.rawCompiledVersion); |
36511 | 327 |
} |
328 |
||
329 |
/** |
|
330 |
* Computes a hash code for this module dependence. |
|
331 |
* |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
332 |
* <p> The hash code is based upon the module name, modifiers, and the |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
333 |
* module version if recorded at compile time. It satisfies the general |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
334 |
* contract of the {@link Object#hashCode Object.hashCode} method. </p> |
36511 | 335 |
* |
336 |
* @return The hash-code value for this module dependence |
|
337 |
*/ |
|
338 |
@Override |
|
339 |
public int hashCode() { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
340 |
int hash = name.hashCode() * 43 + mods.hashCode(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
341 |
if (compiledVersion != null) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
342 |
hash = hash * 43 + compiledVersion.hashCode(); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
343 |
if (rawCompiledVersion != null) |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
344 |
hash = hash * 43 + rawCompiledVersion.hashCode(); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
345 |
return hash; |
36511 | 346 |
} |
347 |
||
348 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
349 |
* Returns a string describing this module dependence. |
36511 | 350 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
351 |
* @return A string describing this module dependence |
36511 | 352 |
*/ |
353 |
@Override |
|
354 |
public String toString() { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
355 |
String what; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
356 |
if (compiledVersion != null) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
357 |
what = name() + " (@" + compiledVersion + ")"; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
358 |
} else { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
359 |
what = name(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
360 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
361 |
return ModuleDescriptor.toString(mods, what); |
36511 | 362 |
} |
363 |
} |
|
364 |
||
365 |
||
366 |
||
367 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
368 |
* <p> A package exported by a module, may be qualified or unqualified. </p> |
36511 | 369 |
* |
370 |
* @see ModuleDescriptor#exports() |
|
371 |
* @since 9 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
372 |
* @spec JPMS |
36511 | 373 |
*/ |
374 |
||
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
375 |
public final static class Exports |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
376 |
implements Comparable<Exports> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
377 |
{ |
36511 | 378 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
379 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
380 |
* A modifier on an exported package. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
381 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
382 |
* @see Exports#modifiers() |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
383 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
384 |
* @spec JPMS |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
385 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
386 |
public static enum Modifier { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
387 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
388 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
389 |
* The export was not explicitly or implicitly declared in the |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
390 |
* source of the module declaration. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
391 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
392 |
SYNTHETIC, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
393 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
394 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
395 |
* The export was implicitly declared in the source of the module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
396 |
* declaration. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
397 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
398 |
MANDATED; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
399 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
400 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
401 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
402 |
private final Set<Modifier> mods; |
36511 | 403 |
private final String source; |
404 |
private final Set<String> targets; // empty if unqualified export |
|
405 |
||
406 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
407 |
* Constructs an export |
36511 | 408 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
409 |
private Exports(Set<Modifier> ms, String source, Set<String> targets) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
410 |
if (ms.isEmpty()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
411 |
ms = Collections.emptySet(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
412 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
413 |
ms = Collections.unmodifiableSet(EnumSet.copyOf(ms)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
414 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
415 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
416 |
this.source = source; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
417 |
this.targets = emptyOrUnmodifiableSet(targets); |
36511 | 418 |
} |
419 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
420 |
private Exports(Set<Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
421 |
String source, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
422 |
Set<String> targets, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
423 |
boolean unused) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
424 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
425 |
this.source = source; |
36511 | 426 |
this.targets = targets; |
427 |
} |
|
428 |
||
429 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
430 |
* Returns the set of modifiers. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
431 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
432 |
* @return A possibly-empty unmodifiable set of modifiers |
36511 | 433 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
434 |
public Set<Modifier> modifiers() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
435 |
return mods; |
36511 | 436 |
} |
437 |
||
438 |
/** |
|
439 |
* Returns {@code true} if this is a qualified export. |
|
440 |
* |
|
441 |
* @return {@code true} if this is a qualified export |
|
442 |
*/ |
|
443 |
public boolean isQualified() { |
|
444 |
return !targets.isEmpty(); |
|
445 |
} |
|
446 |
||
447 |
/** |
|
448 |
* Returns the package name. |
|
449 |
* |
|
450 |
* @return The package name |
|
451 |
*/ |
|
452 |
public String source() { |
|
453 |
return source; |
|
454 |
} |
|
455 |
||
456 |
/** |
|
457 |
* For a qualified export, returns the non-empty and immutable set |
|
458 |
* of the module names to which the package is exported. For an |
|
459 |
* unqualified export, returns an empty set. |
|
460 |
* |
|
461 |
* @return The set of target module names or for an unqualified |
|
462 |
* export, an empty set |
|
463 |
*/ |
|
464 |
public Set<String> targets() { |
|
465 |
return targets; |
|
466 |
} |
|
467 |
||
468 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
469 |
* Compares this module export to another. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
470 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
471 |
* <p> Two {@code Exports} objects are compared by comparing the package |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
472 |
* names lexicographically. Where the packages names are equal then the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
473 |
* sets of modifiers are compared in the same way that module modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
474 |
* are compared (see {@link ModuleDescriptor#compareTo |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
475 |
* ModuleDescriptor.compareTo}). Where the package names are equal and |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
476 |
* the set of modifiers are equal then the set of target modules are |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
477 |
* compared. This is done by sorting the names of the target modules |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
478 |
* in ascending order, and according to their natural ordering, and then |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
479 |
* comparing the corresponding elements lexicographically. Where the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
480 |
* sets differ in size, and the larger set contains all elements of the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
481 |
* smaller set, then the larger set is considered to succeed the smaller |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
482 |
* set. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
483 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
484 |
* @param that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
485 |
* The module export to compare |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
486 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
487 |
* @return A negative integer, zero, or a positive integer if this module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
488 |
* export is less than, equal to, or greater than the given |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
489 |
* export dependence |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
490 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
491 |
@Override |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
492 |
public int compareTo(Exports that) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
493 |
if (this == that) return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
494 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
495 |
int c = source.compareTo(that.source); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
496 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
497 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
498 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
499 |
// modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
500 |
long v1 = modsValue(this.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
501 |
long v2 = modsValue(that.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
502 |
c = Long.compare(v1, v2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
503 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
504 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
505 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
506 |
// targets |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
507 |
c = compare(targets, that.targets); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
508 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
509 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
510 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
511 |
return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
512 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
513 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
514 |
/** |
36511 | 515 |
* Computes a hash code for this module export. |
516 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
517 |
* <p> The hash code is based upon the modifiers, the package name, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
518 |
* and for a qualified export, the set of modules names to which the |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
519 |
* package is exported. It satisfies the general contract of the |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
520 |
* {@link Object#hashCode Object.hashCode} method. |
36511 | 521 |
* |
522 |
* @return The hash-code value for this module export |
|
523 |
*/ |
|
524 |
@Override |
|
525 |
public int hashCode() { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
526 |
int hash = mods.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
527 |
hash = hash * 43 + source.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
528 |
return hash * 43 + targets.hashCode(); |
36511 | 529 |
} |
530 |
||
531 |
/** |
|
532 |
* Tests this module export for equality with the given object. |
|
533 |
* |
|
37880 | 534 |
* <p> If the given object is not an {@code Exports} then this method |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
535 |
* returns {@code false}. Two module exports objects are equal if their |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
536 |
* set of modifiers is equal, the package names are equal and the set |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
537 |
* of target module names is equal. </p> |
36511 | 538 |
* |
539 |
* <p> This method satisfies the general contract of the {@link |
|
540 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
541 |
* |
|
542 |
* @param ob |
|
543 |
* the object to which this object is to be compared |
|
544 |
* |
|
545 |
* @return {@code true} if, and only if, the given object is a module |
|
546 |
* dependence that is equal to this module dependence |
|
547 |
*/ |
|
548 |
@Override |
|
549 |
public boolean equals(Object ob) { |
|
550 |
if (!(ob instanceof Exports)) |
|
551 |
return false; |
|
552 |
Exports other = (Exports)ob; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
553 |
return Objects.equals(this.mods, other.mods) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
554 |
&& Objects.equals(this.source, other.source) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
555 |
&& Objects.equals(this.targets, other.targets); |
36511 | 556 |
} |
557 |
||
558 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
559 |
* Returns a string describing the exported package. |
36511 | 560 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
561 |
* @return A string describing the exported package |
36511 | 562 |
*/ |
563 |
@Override |
|
564 |
public String toString() { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
565 |
String s = ModuleDescriptor.toString(mods, source); |
36511 | 566 |
if (targets.isEmpty()) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
567 |
return s; |
36511 | 568 |
else |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
569 |
return s + " to " + targets; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
570 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
571 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
572 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
573 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
574 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
575 |
* <p> A package opened by a module, may be qualified or unqualified. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
576 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
577 |
* <p> The <em>opens</em> directive in a module declaration declares a |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
578 |
* package to be open to allow all types in the package, and all their |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
579 |
* members, not just public types and their public members to be reflected |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
580 |
* on by APIs that support private access or a way to bypass or suppress |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
581 |
* default Java language access control checks. </p> |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
582 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
583 |
* @see ModuleDescriptor#opens() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
584 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
585 |
* @spec JPMS |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
586 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
587 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
588 |
public final static class Opens |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
589 |
implements Comparable<Opens> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
590 |
{ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
591 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
592 |
* A modifier on an open package. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
593 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
594 |
* @see Opens#modifiers() |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
595 |
* @since 9 |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
596 |
* @spec JPMS |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
597 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
598 |
public static enum Modifier { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
599 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
600 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
601 |
* The open package was not explicitly or implicitly declared in |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
602 |
* the source of the module declaration. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
603 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
604 |
SYNTHETIC, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
605 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
606 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
607 |
* The open package was implicitly declared in the source of the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
608 |
* module declaration. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
609 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
610 |
MANDATED; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
611 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
612 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
613 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
614 |
private final Set<Modifier> mods; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
615 |
private final String source; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
616 |
private final Set<String> targets; // empty if unqualified export |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
617 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
618 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
619 |
* Constructs an Opens |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
620 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
621 |
private Opens(Set<Modifier> ms, String source, Set<String> targets) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
622 |
if (ms.isEmpty()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
623 |
ms = Collections.emptySet(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
624 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
625 |
ms = Collections.unmodifiableSet(EnumSet.copyOf(ms)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
626 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
627 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
628 |
this.source = source; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
629 |
this.targets = emptyOrUnmodifiableSet(targets); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
630 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
631 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
632 |
private Opens(Set<Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
633 |
String source, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
634 |
Set<String> targets, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
635 |
boolean unused) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
636 |
this.mods = ms; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
637 |
this.source = source; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
638 |
this.targets = targets; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
639 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
640 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
641 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
642 |
* Returns the set of modifiers. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
643 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
644 |
* @return A possibly-empty unmodifiable set of modifiers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
645 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
646 |
public Set<Modifier> modifiers() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
647 |
return mods; |
36511 | 648 |
} |
649 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
650 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
651 |
* Returns {@code true} if this is a qualified opens. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
652 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
653 |
* @return {@code true} if this is a qualified opens |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
654 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
655 |
public boolean isQualified() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
656 |
return !targets.isEmpty(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
657 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
658 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
659 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
660 |
* Returns the package name. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
661 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
662 |
* @return The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
663 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
664 |
public String source() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
665 |
return source; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
666 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
667 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
668 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
669 |
* For a qualified opens, returns the non-empty and immutable set |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
670 |
* of the module names to which the package is open. For an |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
671 |
* unqualified opens, returns an empty set. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
672 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
673 |
* @return The set of target module names or for an unqualified |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
674 |
* opens, an empty set |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
675 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
676 |
public Set<String> targets() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
677 |
return targets; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
678 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
679 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
680 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
681 |
* Compares this module opens to another. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
682 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
683 |
* <p> Two {@code Opens} objects are compared by comparing the package |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
684 |
* names lexicographically. Where the packages names are equal then the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
685 |
* sets of modifiers are compared in the same way that module modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
686 |
* are compared (see {@link ModuleDescriptor#compareTo |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
687 |
* ModuleDescriptor.compareTo}). Where the package names are equal and |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
688 |
* the set of modifiers are equal then the set of target modules are |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
689 |
* compared. This is done by sorting the names of the target modules |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
690 |
* in ascending order, and according to their natural ordering, and then |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
691 |
* comparing the corresponding elements lexicographically. Where the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
692 |
* sets differ in size, and the larger set contains all elements of the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
693 |
* smaller set, then the larger set is considered to succeed the smaller |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
694 |
* set. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
695 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
696 |
* @param that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
697 |
* The module opens to compare |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
698 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
699 |
* @return A negative integer, zero, or a positive integer if this module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
700 |
* opens is less than, equal to, or greater than the given |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
701 |
* module opens |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
702 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
703 |
@Override |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
704 |
public int compareTo(Opens that) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
705 |
if (this == that) return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
706 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
707 |
int c = source.compareTo(that.source); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
708 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
709 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
710 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
711 |
// modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
712 |
long v1 = modsValue(this.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
713 |
long v2 = modsValue(that.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
714 |
c = Long.compare(v1, v2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
715 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
716 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
717 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
718 |
// targets |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
719 |
c = compare(targets, that.targets); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
720 |
if (c != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
721 |
return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
722 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
723 |
return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
724 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
725 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
726 |
/** |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
727 |
* Computes a hash code for this module opens. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
728 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
729 |
* <p> The hash code is based upon the modifiers, the package name, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
730 |
* and for a qualified opens, the set of modules names to which the |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
731 |
* package is opened. It satisfies the general contract of the |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
732 |
* {@link Object#hashCode Object.hashCode} method. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
733 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
734 |
* @return The hash-code value for this module opens |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
735 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
736 |
@Override |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
737 |
public int hashCode() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
738 |
int hash = mods.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
739 |
hash = hash * 43 + source.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
740 |
return hash * 43 + targets.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
741 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
742 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
743 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
744 |
* Tests this module opens for equality with the given object. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
745 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
746 |
* <p> If the given object is not an {@code Opens} then this method |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
747 |
* returns {@code false}. Two {@code Opens} objects are equal if their |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
748 |
* set of modifiers is equal, the package names are equal and the set |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
749 |
* of target module names is equal. </p> |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
750 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
751 |
* <p> This method satisfies the general contract of the {@link |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
752 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
753 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
754 |
* @param ob |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
755 |
* the object to which this object is to be compared |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
756 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
757 |
* @return {@code true} if, and only if, the given object is a module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
758 |
* dependence that is equal to this module dependence |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
759 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
760 |
@Override |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
761 |
public boolean equals(Object ob) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
762 |
if (!(ob instanceof Opens)) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
763 |
return false; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
764 |
Opens other = (Opens)ob; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
765 |
return Objects.equals(this.mods, other.mods) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
766 |
&& Objects.equals(this.source, other.source) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
767 |
&& Objects.equals(this.targets, other.targets); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
768 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
769 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
770 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
771 |
* Returns a string describing the open package. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
772 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
773 |
* @return A string describing the open package |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
774 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
775 |
@Override |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
776 |
public String toString() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
777 |
String s = ModuleDescriptor.toString(mods, source); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
778 |
if (targets.isEmpty()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
779 |
return s; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
780 |
else |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
781 |
return s + " to " + targets; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
782 |
} |
36511 | 783 |
} |
784 |
||
785 |
||
786 |
/** |
|
787 |
* <p> A service that a module provides one or more implementations of. </p> |
|
788 |
* |
|
789 |
* @see ModuleDescriptor#provides() |
|
790 |
* @since 9 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
791 |
* @spec JPMS |
36511 | 792 |
*/ |
793 |
||
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
794 |
public final static class Provides |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
795 |
implements Comparable<Provides> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
796 |
{ |
36511 | 797 |
private final String service; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
798 |
private final List<String> providers; |
36511 | 799 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
800 |
private Provides(String service, List<String> providers) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
801 |
this.service = service; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
802 |
this.providers = Collections.unmodifiableList(providers); |
36511 | 803 |
} |
804 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
805 |
private Provides(String service, List<String> providers, boolean unused) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
806 |
this.service = service; |
36511 | 807 |
this.providers = providers; |
808 |
} |
|
809 |
||
810 |
/** |
|
811 |
* Returns the fully qualified class name of the service type. |
|
812 |
* |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
813 |
* @return The fully qualified class name of the service type |
36511 | 814 |
*/ |
815 |
public String service() { return service; } |
|
816 |
||
817 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
818 |
* Returns the list of the fully qualified class names of the providers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
819 |
* or provider factories. |
36511 | 820 |
* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
821 |
* @return A non-empty and unmodifiable list of the fully qualified class |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
822 |
* names of the providers or provider factories |
36511 | 823 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
824 |
public List<String> providers() { return providers; } |
36511 | 825 |
|
826 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
827 |
* Compares this provides to another. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
828 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
829 |
* <p> Two {@code Provides} objects are compared by comparing the fully |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
830 |
* qualified class name of the service type lexicographically. Where the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
831 |
* class names are equal then the list of the provider class names are |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
832 |
* compared by comparing the corresponding elements of both lists |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
833 |
* lexicographically and in sequence. Where the lists differ in size, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
834 |
* {@code N} is the size of the shorter list, and the first {@code N} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
835 |
* corresponding elements are equal, then the longer list is considered |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
836 |
* to succeed the shorter list. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
837 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
838 |
* @param that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
839 |
* The {@code Provides} to compare |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
840 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
841 |
* @return A negative integer, zero, or a positive integer if this provides |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
842 |
* is less than, equal to, or greater than the given provides |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
843 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
844 |
public int compareTo(Provides that) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
845 |
if (this == that) return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
846 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
847 |
int c = service.compareTo(that.service); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
848 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
849 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
850 |
// compare provider class names in sequence |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
851 |
int size1 = this.providers.size(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
852 |
int size2 = that.providers.size(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
853 |
for (int index=0; index<Math.min(size1, size2); index++) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
854 |
String e1 = this.providers.get(index); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
855 |
String e2 = that.providers.get(index); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
856 |
c = e1.compareTo(e2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
857 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
858 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
859 |
if (size1 == size2) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
860 |
return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
861 |
} else { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
862 |
return (size1 > size2) ? 1 : -1; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
863 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
864 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
865 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
866 |
/** |
36511 | 867 |
* Computes a hash code for this provides. |
868 |
* |
|
869 |
* <p> The hash code is based upon the service type and the set of |
|
870 |
* providers. It satisfies the general contract of the {@link |
|
871 |
* Object#hashCode Object.hashCode} method. </p> |
|
872 |
* |
|
873 |
* @return The hash-code value for this module provides |
|
874 |
*/ |
|
875 |
@Override |
|
876 |
public int hashCode() { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
877 |
return service.hashCode() * 43 + providers.hashCode(); |
36511 | 878 |
} |
879 |
||
880 |
/** |
|
881 |
* Tests this provides for equality with the given object. |
|
882 |
* |
|
883 |
* <p> If the given object is not a {@code Provides} then this method |
|
884 |
* returns {@code false}. Two {@code Provides} objects are equal if the |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
885 |
* service type is equal and the list of providers is equal. </p> |
36511 | 886 |
* |
887 |
* <p> This method satisfies the general contract of the {@link |
|
888 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
889 |
* |
|
890 |
* @param ob |
|
891 |
* the object to which this object is to be compared |
|
892 |
* |
|
893 |
* @return {@code true} if, and only if, the given object is a |
|
894 |
* {@code Provides} that is equal to this {@code Provides} |
|
895 |
*/ |
|
896 |
@Override |
|
897 |
public boolean equals(Object ob) { |
|
898 |
if (!(ob instanceof Provides)) |
|
899 |
return false; |
|
900 |
Provides other = (Provides)ob; |
|
901 |
return Objects.equals(this.service, other.service) && |
|
902 |
Objects.equals(this.providers, other.providers); |
|
903 |
} |
|
904 |
||
905 |
/** |
|
906 |
* Returns a string describing this provides. |
|
907 |
* |
|
908 |
* @return A string describing this provides |
|
909 |
*/ |
|
910 |
@Override |
|
911 |
public String toString() { |
|
912 |
return service + " with " + providers; |
|
913 |
} |
|
914 |
||
915 |
} |
|
916 |
||
917 |
||
918 |
||
919 |
/** |
|
920 |
* A module's version string. |
|
921 |
* |
|
922 |
* <p> A version string has three components: The version number itself, an |
|
923 |
* optional pre-release version, and an optional build version. Each |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
924 |
* component is a sequence of tokens; each token is either a non-negative |
36511 | 925 |
* integer or a string. Tokens are separated by the punctuation characters |
926 |
* {@code '.'}, {@code '-'}, or {@code '+'}, or by transitions from a |
|
927 |
* sequence of digits to a sequence of characters that are neither digits |
|
928 |
* nor punctuation characters, or vice versa. |
|
929 |
* |
|
930 |
* <ul> |
|
931 |
* |
|
932 |
* <li> The <i>version number</i> is a sequence of tokens separated by |
|
933 |
* {@code '.'} characters, terminated by the first {@code '-'} or {@code |
|
934 |
* '+'} character. </li> |
|
935 |
* |
|
936 |
* <li> The <i>pre-release version</i> is a sequence of tokens separated |
|
937 |
* by {@code '.'} or {@code '-'} characters, terminated by the first |
|
938 |
* {@code '+'} character. </li> |
|
939 |
* |
|
940 |
* <li> The <i>build version</i> is a sequence of tokens separated by |
|
941 |
* {@code '.'}, {@code '-'}, or {@code '+'} characters. |
|
942 |
* |
|
943 |
* </ul> |
|
944 |
* |
|
945 |
* <p> When comparing two version strings, the elements of their |
|
946 |
* corresponding components are compared in pointwise fashion. If one |
|
947 |
* component is longer than the other, but otherwise equal to it, then the |
|
948 |
* first component is considered the greater of the two; otherwise, if two |
|
949 |
* corresponding elements are integers then they are compared as such; |
|
950 |
* otherwise, at least one of the elements is a string, so the other is |
|
951 |
* converted into a string if it is an integer and the two are compared |
|
952 |
* lexicographically. Trailing integer elements with the value zero are |
|
953 |
* ignored. |
|
954 |
* |
|
955 |
* <p> Given two version strings, if their version numbers differ then the |
|
956 |
* result of comparing them is the result of comparing their version |
|
957 |
* numbers; otherwise, if one of them has a pre-release version but the |
|
958 |
* other does not then the first is considered to precede the second, |
|
959 |
* otherwise the result of comparing them is the result of comparing their |
|
960 |
* pre-release versions; otherwise, the result of comparing them is the |
|
961 |
* result of comparing their build versions. |
|
962 |
* |
|
963 |
* @see ModuleDescriptor#version() |
|
964 |
* @since 9 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
965 |
* @spec JPMS |
36511 | 966 |
*/ |
967 |
||
968 |
public final static class Version |
|
969 |
implements Comparable<Version> |
|
970 |
{ |
|
971 |
||
972 |
private final String version; |
|
973 |
||
974 |
// If Java had disjunctive types then we'd write List<Integer|String> here |
|
975 |
// |
|
976 |
private final List<Object> sequence; |
|
977 |
private final List<Object> pre; |
|
978 |
private final List<Object> build; |
|
979 |
||
980 |
// Take a numeric token starting at position i |
|
981 |
// Append it to the given list |
|
982 |
// Return the index of the first character not taken |
|
983 |
// Requires: s.charAt(i) is (decimal) numeric |
|
984 |
// |
|
985 |
private static int takeNumber(String s, int i, List<Object> acc) { |
|
986 |
char c = s.charAt(i); |
|
987 |
int d = (c - '0'); |
|
988 |
int n = s.length(); |
|
989 |
while (++i < n) { |
|
990 |
c = s.charAt(i); |
|
991 |
if (c >= '0' && c <= '9') { |
|
992 |
d = d * 10 + (c - '0'); |
|
993 |
continue; |
|
994 |
} |
|
995 |
break; |
|
996 |
} |
|
997 |
acc.add(d); |
|
998 |
return i; |
|
999 |
} |
|
1000 |
||
1001 |
// Take a string token starting at position i |
|
1002 |
// Append it to the given list |
|
1003 |
// Return the index of the first character not taken |
|
1004 |
// Requires: s.charAt(i) is not '.' |
|
1005 |
// |
|
1006 |
private static int takeString(String s, int i, List<Object> acc) { |
|
1007 |
int b = i; |
|
1008 |
int n = s.length(); |
|
1009 |
while (++i < n) { |
|
1010 |
char c = s.charAt(i); |
|
1011 |
if (c != '.' && c != '-' && c != '+' && !(c >= '0' && c <= '9')) |
|
1012 |
continue; |
|
1013 |
break; |
|
1014 |
} |
|
1015 |
acc.add(s.substring(b, i)); |
|
1016 |
return i; |
|
1017 |
} |
|
1018 |
||
1019 |
// Syntax: tok+ ( '-' tok+)? ( '+' tok+)? |
|
1020 |
// First token string is sequence, second is pre, third is build |
|
1021 |
// Tokens are separated by '.' or '-', or by changes between alpha & numeric |
|
1022 |
// Numeric tokens are compared as decimal integers |
|
1023 |
// Non-numeric tokens are compared lexicographically |
|
1024 |
// A version with a non-empty pre is less than a version with same seq but no pre |
|
1025 |
// Tokens in build may contain '-' and '+' |
|
1026 |
// |
|
1027 |
private Version(String v) { |
|
1028 |
||
1029 |
if (v == null) |
|
1030 |
throw new IllegalArgumentException("Null version string"); |
|
1031 |
int n = v.length(); |
|
1032 |
if (n == 0) |
|
1033 |
throw new IllegalArgumentException("Empty version string"); |
|
1034 |
||
1035 |
int i = 0; |
|
1036 |
char c = v.charAt(i); |
|
1037 |
if (!(c >= '0' && c <= '9')) |
|
1038 |
throw new IllegalArgumentException(v |
|
1039 |
+ ": Version string does not start" |
|
1040 |
+ " with a number"); |
|
1041 |
||
1042 |
List<Object> sequence = new ArrayList<>(4); |
|
1043 |
List<Object> pre = new ArrayList<>(2); |
|
1044 |
List<Object> build = new ArrayList<>(2); |
|
1045 |
||
1046 |
i = takeNumber(v, i, sequence); |
|
1047 |
||
1048 |
while (i < n) { |
|
1049 |
c = v.charAt(i); |
|
1050 |
if (c == '.') { |
|
1051 |
i++; |
|
1052 |
continue; |
|
1053 |
} |
|
1054 |
if (c == '-' || c == '+') { |
|
1055 |
i++; |
|
1056 |
break; |
|
1057 |
} |
|
1058 |
if (c >= '0' && c <= '9') |
|
1059 |
i = takeNumber(v, i, sequence); |
|
1060 |
else |
|
1061 |
i = takeString(v, i, sequence); |
|
1062 |
} |
|
1063 |
||
1064 |
if (c == '-' && i >= n) |
|
1065 |
throw new IllegalArgumentException(v + ": Empty pre-release"); |
|
1066 |
||
1067 |
while (i < n) { |
|
1068 |
c = v.charAt(i); |
|
1069 |
if (c >= '0' && c <= '9') |
|
1070 |
i = takeNumber(v, i, pre); |
|
1071 |
else |
|
1072 |
i = takeString(v, i, pre); |
|
1073 |
if (i >= n) |
|
1074 |
break; |
|
1075 |
c = v.charAt(i); |
|
1076 |
if (c == '.' || c == '-') { |
|
1077 |
i++; |
|
1078 |
continue; |
|
1079 |
} |
|
1080 |
if (c == '+') { |
|
1081 |
i++; |
|
1082 |
break; |
|
1083 |
} |
|
1084 |
} |
|
1085 |
||
1086 |
if (c == '+' && i >= n) |
|
1087 |
throw new IllegalArgumentException(v + ": Empty pre-release"); |
|
1088 |
||
1089 |
while (i < n) { |
|
1090 |
c = v.charAt(i); |
|
1091 |
if (c >= '0' && c <= '9') |
|
1092 |
i = takeNumber(v, i, build); |
|
1093 |
else |
|
1094 |
i = takeString(v, i, build); |
|
1095 |
if (i >= n) |
|
1096 |
break; |
|
1097 |
c = v.charAt(i); |
|
1098 |
if (c == '.' || c == '-' || c == '+') { |
|
1099 |
i++; |
|
1100 |
continue; |
|
1101 |
} |
|
1102 |
} |
|
1103 |
||
1104 |
this.version = v; |
|
1105 |
this.sequence = sequence; |
|
1106 |
this.pre = pre; |
|
1107 |
this.build = build; |
|
1108 |
} |
|
1109 |
||
1110 |
/** |
|
1111 |
* Parses the given string as a version string. |
|
1112 |
* |
|
1113 |
* @param v |
|
1114 |
* The string to parse |
|
1115 |
* |
|
1116 |
* @return The resulting {@code Version} |
|
1117 |
* |
|
1118 |
* @throws IllegalArgumentException |
|
1119 |
* If {@code v} is {@code null}, an empty string, or cannot be |
|
1120 |
* parsed as a version string |
|
1121 |
*/ |
|
1122 |
public static Version parse(String v) { |
|
1123 |
return new Version(v); |
|
1124 |
} |
|
1125 |
||
1126 |
@SuppressWarnings("unchecked") |
|
1127 |
private int cmp(Object o1, Object o2) { |
|
1128 |
return ((Comparable)o1).compareTo(o2); |
|
1129 |
} |
|
1130 |
||
1131 |
private int compareTokens(List<Object> ts1, List<Object> ts2) { |
|
1132 |
int n = Math.min(ts1.size(), ts2.size()); |
|
1133 |
for (int i = 0; i < n; i++) { |
|
1134 |
Object o1 = ts1.get(i); |
|
1135 |
Object o2 = ts2.get(i); |
|
1136 |
if ((o1 instanceof Integer && o2 instanceof Integer) |
|
1137 |
|| (o1 instanceof String && o2 instanceof String)) |
|
1138 |
{ |
|
1139 |
int c = cmp(o1, o2); |
|
1140 |
if (c == 0) |
|
1141 |
continue; |
|
1142 |
return c; |
|
1143 |
} |
|
1144 |
// Types differ, so convert number to string form |
|
1145 |
int c = o1.toString().compareTo(o2.toString()); |
|
1146 |
if (c == 0) |
|
1147 |
continue; |
|
1148 |
return c; |
|
1149 |
} |
|
1150 |
List<Object> rest = ts1.size() > ts2.size() ? ts1 : ts2; |
|
1151 |
int e = rest.size(); |
|
1152 |
for (int i = n; i < e; i++) { |
|
1153 |
Object o = rest.get(i); |
|
1154 |
if (o instanceof Integer && ((Integer)o) == 0) |
|
1155 |
continue; |
|
1156 |
return ts1.size() - ts2.size(); |
|
1157 |
} |
|
1158 |
return 0; |
|
1159 |
} |
|
1160 |
||
1161 |
/** |
|
1162 |
* Compares this module version to another module version. Module |
|
1163 |
* versions are compared as described in the class description. |
|
1164 |
* |
|
1165 |
* @param that |
|
1166 |
* The module version to compare |
|
1167 |
* |
|
1168 |
* @return A negative integer, zero, or a positive integer as this |
|
1169 |
* module version is less than, equal to, or greater than the |
|
1170 |
* given module version |
|
1171 |
*/ |
|
1172 |
@Override |
|
1173 |
public int compareTo(Version that) { |
|
1174 |
int c = compareTokens(this.sequence, that.sequence); |
|
1175 |
if (c != 0) return c; |
|
1176 |
if (this.pre.isEmpty()) { |
|
1177 |
if (!that.pre.isEmpty()) return +1; |
|
1178 |
} else { |
|
1179 |
if (that.pre.isEmpty()) return -1; |
|
1180 |
} |
|
1181 |
c = compareTokens(this.pre, that.pre); |
|
1182 |
if (c != 0) return c; |
|
1183 |
return compareTokens(this.build, that.build); |
|
1184 |
} |
|
1185 |
||
1186 |
/** |
|
1187 |
* Tests this module version for equality with the given object. |
|
1188 |
* |
|
1189 |
* <p> If the given object is not a {@code Version} then this method |
|
1190 |
* returns {@code false}. Two module version are equal if their |
|
1191 |
* corresponding components are equal. </p> |
|
1192 |
* |
|
1193 |
* <p> This method satisfies the general contract of the {@link |
|
1194 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
1195 |
* |
|
1196 |
* @param ob |
|
1197 |
* the object to which this object is to be compared |
|
1198 |
* |
|
1199 |
* @return {@code true} if, and only if, the given object is a module |
|
1200 |
* reference that is equal to this module reference |
|
1201 |
*/ |
|
1202 |
@Override |
|
1203 |
public boolean equals(Object ob) { |
|
1204 |
if (!(ob instanceof Version)) |
|
1205 |
return false; |
|
1206 |
return compareTo((Version)ob) == 0; |
|
1207 |
} |
|
1208 |
||
1209 |
/** |
|
1210 |
* Computes a hash code for this module version. |
|
1211 |
* |
|
1212 |
* <p> The hash code is based upon the components of the version and |
|
1213 |
* satisfies the general contract of the {@link Object#hashCode |
|
1214 |
* Object.hashCode} method. </p> |
|
1215 |
* |
|
1216 |
* @return The hash-code value for this module version |
|
1217 |
*/ |
|
1218 |
@Override |
|
1219 |
public int hashCode() { |
|
1220 |
return version.hashCode(); |
|
1221 |
} |
|
1222 |
||
1223 |
/** |
|
1224 |
* Returns the string from which this version was parsed. |
|
1225 |
* |
|
1226 |
* @return The string from which this version was parsed. |
|
1227 |
*/ |
|
1228 |
@Override |
|
1229 |
public String toString() { |
|
1230 |
return version; |
|
1231 |
} |
|
1232 |
||
1233 |
} |
|
1234 |
||
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1235 |
|
36511 | 1236 |
private final String name; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1237 |
private final Version version; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1238 |
private final String rawVersionString; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1239 |
private final Set<Modifier> modifiers; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1240 |
private final boolean open; // true if modifiers contains OPEN |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1241 |
private final boolean automatic; // true if modifiers contains AUTOMATIC |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1242 |
private final Set<Requires> requires; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1243 |
private final Set<Exports> exports; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1244 |
private final Set<Opens> opens; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1245 |
private final Set<String> uses; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1246 |
private final Set<Provides> provides; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1247 |
private final Set<String> packages; |
36511 | 1248 |
private final String mainClass; |
1249 |
||
1250 |
private ModuleDescriptor(String name, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1251 |
Version version, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1252 |
String rawVersionString, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1253 |
Set<Modifier> modifiers, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1254 |
Set<Requires> requires, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1255 |
Set<Exports> exports, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1256 |
Set<Opens> opens, |
36511 | 1257 |
Set<String> uses, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1258 |
Set<Provides> provides, |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1259 |
Set<String> packages, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1260 |
String mainClass) |
36511 | 1261 |
{ |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1262 |
assert version == null || rawVersionString == null; |
36511 | 1263 |
this.name = name; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1264 |
this.version = version; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1265 |
this.rawVersionString = rawVersionString; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1266 |
this.modifiers = emptyOrUnmodifiableSet(modifiers); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1267 |
this.open = modifiers.contains(Modifier.OPEN); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1268 |
this.automatic = modifiers.contains(Modifier.AUTOMATIC); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1269 |
assert (requires.stream().map(Requires::name).distinct().count() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1270 |
== requires.size()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1271 |
this.requires = emptyOrUnmodifiableSet(requires); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1272 |
this.exports = emptyOrUnmodifiableSet(exports); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1273 |
this.opens = emptyOrUnmodifiableSet(opens); |
36511 | 1274 |
this.uses = emptyOrUnmodifiableSet(uses); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1275 |
this.provides = emptyOrUnmodifiableSet(provides); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1276 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1277 |
this.packages = emptyOrUnmodifiableSet(packages); |
36511 | 1278 |
this.mainClass = mainClass; |
1279 |
} |
|
1280 |
||
1281 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1282 |
* Creates a module descriptor from its components. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1283 |
* The arguments are pre-validated and sets are unmodifiable sets. |
36511 | 1284 |
*/ |
1285 |
ModuleDescriptor(String name, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1286 |
Version version, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1287 |
Set<Modifier> modifiers, |
36511 | 1288 |
Set<Requires> requires, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1289 |
Set<Exports> exports, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1290 |
Set<Opens> opens, |
36511 | 1291 |
Set<String> uses, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1292 |
Set<Provides> provides, |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1293 |
Set<String> packages, |
36511 | 1294 |
String mainClass, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1295 |
int hashCode, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1296 |
boolean unused) { |
36511 | 1297 |
this.name = name; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1298 |
this.version = version; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1299 |
this.rawVersionString = null; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1300 |
this.modifiers = modifiers; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1301 |
this.open = modifiers.contains(Modifier.OPEN); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1302 |
this.automatic = modifiers.contains(Modifier.AUTOMATIC); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1303 |
this.requires = requires; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1304 |
this.exports = exports; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1305 |
this.opens = opens; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1306 |
this.uses = uses; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1307 |
this.provides = provides; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1308 |
this.packages = packages; |
36511 | 1309 |
this.mainClass = mainClass; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1310 |
this.hash = hashCode; |
36511 | 1311 |
} |
1312 |
||
1313 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1314 |
* <p> Returns the module name. </p> |
36511 | 1315 |
* |
1316 |
* @return The module name |
|
1317 |
*/ |
|
1318 |
public String name() { |
|
1319 |
return name; |
|
1320 |
} |
|
1321 |
||
1322 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1323 |
* <p> Returns the set of module modifiers. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1324 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1325 |
* @return A possibly-empty unmodifiable set of modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1326 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1327 |
public Set<Modifier> modifiers() { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1328 |
return modifiers; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1329 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1330 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1331 |
/** |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1332 |
* <p> Returns {@code true} if this is an open module. </p> |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1333 |
* |
47004 | 1334 |
* <p> This method is equivalent to testing if the set of {@link #modifiers() |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1335 |
* modifiers} contains the {@link Modifier#OPEN OPEN} modifier. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1336 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1337 |
* @return {@code true} if this is an open module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1338 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1339 |
public boolean isOpen() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1340 |
return open; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1341 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1342 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1343 |
/** |
36511 | 1344 |
* <p> Returns {@code true} if this is an automatic module. </p> |
1345 |
* |
|
47004 | 1346 |
* <p> This method is equivalent to testing if the set of {@link #modifiers() |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1347 |
* modifiers} contains the {@link Modifier#OPEN AUTOMATIC} modifier. </p> |
36511 | 1348 |
* |
1349 |
* @return {@code true} if this is an automatic module |
|
1350 |
*/ |
|
1351 |
public boolean isAutomatic() { |
|
1352 |
return automatic; |
|
1353 |
} |
|
1354 |
||
1355 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1356 |
* <p> Returns the set of {@code Requires} objects representing the module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1357 |
* dependences. </p> |
36511 | 1358 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1359 |
* <p> The set includes a dependency on "{@code java.base}" when this |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1360 |
* module is not named "{@code java.base}". If this module is an automatic |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1361 |
* module then it does not have a dependency on any module other than |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1362 |
* "{@code java.base}". </p> |
36511 | 1363 |
* |
1364 |
* @return A possibly-empty unmodifiable set of {@link Requires} objects |
|
1365 |
*/ |
|
1366 |
public Set<Requires> requires() { |
|
1367 |
return requires; |
|
1368 |
} |
|
1369 |
||
1370 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1371 |
* <p> Returns the set of {@code Exports} objects representing the exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1372 |
* packages. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1373 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1374 |
* <p> If this module is an automatic module then the set of exports |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1375 |
* is empty. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1376 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1377 |
* @return A possibly-empty unmodifiable set of exported packages |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1378 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1379 |
public Set<Exports> exports() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1380 |
return exports; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1381 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1382 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1383 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1384 |
* <p> Returns the set of {@code Opens} objects representing the open |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1385 |
* packages. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1386 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1387 |
* <p> If this module is an open module or an automatic module then the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1388 |
* set of open packages is empty. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1389 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1390 |
* @return A possibly-empty unmodifiable set of open packages |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1391 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1392 |
public Set<Opens> opens() { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1393 |
return opens; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1394 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1395 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1396 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1397 |
* <p> Returns the set of service dependences. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1398 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1399 |
* <p> If this module is an automatic module then the set of service |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1400 |
* dependences is empty. </p> |
36511 | 1401 |
* |
1402 |
* @return A possibly-empty unmodifiable set of the fully qualified class |
|
1403 |
* names of the service types used |
|
1404 |
*/ |
|
1405 |
public Set<String> uses() { |
|
1406 |
return uses; |
|
1407 |
} |
|
1408 |
||
1409 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1410 |
* <p> Returns the set of {@code Provides} objects representing the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1411 |
* services that the module provides. </p> |
36511 | 1412 |
* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1413 |
* @return The possibly-empty unmodifiable set of the services that this |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1414 |
* module provides |
36511 | 1415 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1416 |
public Set<Provides> provides() { |
36511 | 1417 |
return provides; |
1418 |
} |
|
1419 |
||
1420 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1421 |
* <p> Returns the module version. </p> |
36511 | 1422 |
* |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1423 |
* @return This module's version, or an empty {@code Optional} if the |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1424 |
* module does not have a version or the version is |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1425 |
* {@linkplain Version#parse(String) unparseable} |
36511 | 1426 |
*/ |
1427 |
public Optional<Version> version() { |
|
1428 |
return Optional.ofNullable(version); |
|
1429 |
} |
|
1430 |
||
1431 |
/** |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1432 |
* <p> Returns the string with the possibly-unparseable version of the |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1433 |
* module </p> |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1434 |
* |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1435 |
* @return The string containing the version of the module or an empty |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1436 |
* {@code Optional} if the module does not have a version |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1437 |
* |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1438 |
* @see #version() |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1439 |
*/ |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1440 |
public Optional<String> rawVersion() { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1441 |
if (version != null) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1442 |
return Optional.of(version.toString()); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1443 |
} else { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1444 |
return Optional.ofNullable(rawVersionString); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1445 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1446 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1447 |
|
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1448 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1449 |
* <p> Returns a string containing the module name and, if present, its |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1450 |
* version. </p> |
36511 | 1451 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1452 |
* @return A string containing the module name and, if present, its |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1453 |
* version |
36511 | 1454 |
*/ |
1455 |
public String toNameAndVersion() { |
|
1456 |
if (version != null) { |
|
1457 |
return name() + "@" + version; |
|
1458 |
} else { |
|
1459 |
return name(); |
|
1460 |
} |
|
1461 |
} |
|
1462 |
||
1463 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1464 |
* <p> Returns the module main class. </p> |
36511 | 1465 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1466 |
* @return The fully qualified class name of the module's main class |
36511 | 1467 |
*/ |
1468 |
public Optional<String> mainClass() { |
|
1469 |
return Optional.ofNullable(mainClass); |
|
1470 |
} |
|
1471 |
||
1472 |
/** |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1473 |
* Returns the set of packages in the module. |
36511 | 1474 |
* |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1475 |
* <p> The set of packages includes all exported and open packages, as well |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1476 |
* as the packages of any service providers, and the package for the main |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1477 |
* class. </p> |
36511 | 1478 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1479 |
* @return A possibly-empty unmodifiable set of the packages in the module |
36511 | 1480 |
*/ |
1481 |
public Set<String> packages() { |
|
1482 |
return packages; |
|
1483 |
} |
|
1484 |
||
1485 |
||
1486 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1487 |
* A builder for building {@link ModuleDescriptor} objects. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1488 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1489 |
* <p> {@code ModuleDescriptor} defines the {@link #newModule newModule}, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1490 |
* {@link #newOpenModule newOpenModule}, and {@link #newAutomaticModule |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1491 |
* newAutomaticModule} methods to create builders for building |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1492 |
* <em>normal</em>, open, and automatic modules. </p> |
36511 | 1493 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1494 |
* <p> The set of packages in the module are accumulated by the {@code |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1495 |
* Builder} as the {@link ModuleDescriptor.Builder#exports(String) exports}, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1496 |
* {@link ModuleDescriptor.Builder#opens(String) opens}, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1497 |
* {@link ModuleDescriptor.Builder#packages(Set) packages}, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1498 |
* {@link ModuleDescriptor.Builder#provides(String,List) provides}, and |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1499 |
* {@link ModuleDescriptor.Builder#mainClass(String) mainClass} methods are |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1500 |
* invoked. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1501 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1502 |
* <p> The module names, package names, and class names that are parameters |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1503 |
* specified to the builder methods are the module names, package names, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1504 |
* and qualified names of classes (in named packages) as defined in the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1505 |
* <cite>The Java™ Language Specification</cite>. </p> |
36511 | 1506 |
* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1507 |
* <p> Example usage: </p> |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1508 |
* <pre>{@code ModuleDescriptor descriptor = ModuleDescriptor.newModule("stats.core") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1509 |
* .requires("java.base") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1510 |
* .exports("org.acme.stats.core.clustering") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1511 |
* .exports("org.acme.stats.core.regression") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1512 |
* .packages(Set.of("org.acme.stats.core.internal")) |
36511 | 1513 |
* .build(); |
1514 |
* }</pre> |
|
1515 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1516 |
* @apiNote A {@code Builder} checks the components and invariants as |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1517 |
* components are added to the builder. The rationale for this is to detect |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1518 |
* errors as early as possible and not defer all validation to the |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1519 |
* {@link #build build} method. |
36511 | 1520 |
* |
1521 |
* @since 9 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1522 |
* @spec JPMS |
36511 | 1523 |
*/ |
1524 |
public static final class Builder { |
|
1525 |
final String name; |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1526 |
final boolean strict; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1527 |
final Set<Modifier> modifiers; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1528 |
final boolean open; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1529 |
final boolean automatic; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1530 |
final Set<String> packages = new HashSet<>(); |
36511 | 1531 |
final Map<String, Requires> requires = new HashMap<>(); |
1532 |
final Map<String, Exports> exports = new HashMap<>(); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1533 |
final Map<String, Opens> opens = new HashMap<>(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1534 |
final Set<String> uses = new HashSet<>(); |
36511 | 1535 |
final Map<String, Provides> provides = new HashMap<>(); |
1536 |
Version version; |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1537 |
String rawVersionString; |
36511 | 1538 |
String mainClass; |
1539 |
||
1540 |
/** |
|
1541 |
* Initializes a new builder with the given module name. |
|
1542 |
* |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1543 |
* If {@code strict} is {@code true} then module, package, and class |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1544 |
* names are checked to ensure they are legal names. In addition, the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1545 |
* {@link #build buid} method will add "{@code requires java.base}" if |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1546 |
* the dependency is not declared. |
36511 | 1547 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1548 |
Builder(String name, boolean strict, Set<Modifier> modifiers) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1549 |
this.name = (strict) ? requireModuleName(name) : name; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1550 |
this.strict = strict; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1551 |
this.modifiers = modifiers; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1552 |
this.open = modifiers.contains(Modifier.OPEN); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1553 |
this.automatic = modifiers.contains(Modifier.AUTOMATIC); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1554 |
assert !open || !automatic; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1555 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1556 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1557 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1558 |
* Returns a snapshot of the packages in the module. |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1559 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1560 |
/* package */ Set<String> packages() { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1561 |
return Collections.unmodifiableSet(packages); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1562 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1563 |
|
36511 | 1564 |
/** |
1565 |
* Adds a dependence on a module. |
|
1566 |
* |
|
1567 |
* @param req |
|
1568 |
* The dependence |
|
1569 |
* |
|
1570 |
* @return This builder |
|
1571 |
* |
|
1572 |
* @throws IllegalArgumentException |
|
1573 |
* If the dependence is on the module that this builder was |
|
1574 |
* initialized to build |
|
1575 |
* @throws IllegalStateException |
|
1576 |
* If the dependence on the module has already been declared |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1577 |
* or this builder is for an automatic module |
36511 | 1578 |
*/ |
1579 |
public Builder requires(Requires req) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1580 |
if (automatic) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1581 |
throw new IllegalStateException("Automatic modules cannot declare" |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1582 |
+ " dependences"); |
36511 | 1583 |
String mn = req.name(); |
1584 |
if (name.equals(mn)) |
|
1585 |
throw new IllegalArgumentException("Dependence on self"); |
|
1586 |
if (requires.containsKey(mn)) |
|
1587 |
throw new IllegalStateException("Dependence upon " + mn |
|
1588 |
+ " already declared"); |
|
1589 |
requires.put(mn, req); |
|
1590 |
return this; |
|
1591 |
} |
|
1592 |
||
1593 |
/** |
|
1594 |
* Adds a dependence on a module with the given (and possibly empty) |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1595 |
* set of modifiers. The dependence includes the version of the |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1596 |
* module that that was recorded at compile-time. |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1597 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1598 |
* @param ms |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1599 |
* The set of modifiers |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1600 |
* @param mn |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1601 |
* The module name |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1602 |
* @param compiledVersion |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1603 |
* The version of the module recorded at compile-time |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1604 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1605 |
* @return This builder |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1606 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1607 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1608 |
* If the module name is {@code null}, is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1609 |
* name, or is equal to the module name that this builder |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1610 |
* was initialized to build |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1611 |
* @throws IllegalStateException |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1612 |
* If the dependence on the module has already been declared |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1613 |
* or this builder is for an automatic module |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1614 |
*/ |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1615 |
public Builder requires(Set<Requires.Modifier> ms, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1616 |
String mn, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1617 |
Version compiledVersion) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1618 |
Objects.requireNonNull(compiledVersion); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1619 |
if (strict) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1620 |
mn = requireModuleName(mn); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1621 |
return requires(new Requires(ms, mn, compiledVersion, null)); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1622 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1623 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1624 |
/* package */Builder requires(Set<Requires.Modifier> ms, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1625 |
String mn, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1626 |
String rawCompiledVersion) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1627 |
Requires r; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1628 |
try { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1629 |
Version v = Version.parse(rawCompiledVersion); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1630 |
r = new Requires(ms, mn, v, null); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1631 |
} catch (IllegalArgumentException e) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1632 |
if (strict) throw e; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1633 |
r = new Requires(ms, mn, null, rawCompiledVersion); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1634 |
} |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1635 |
return requires(r); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1636 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1637 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1638 |
/** |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
1639 |
* Adds a dependence on a module with the given (and possibly empty) |
36511 | 1640 |
* set of modifiers. |
1641 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1642 |
* @param ms |
36511 | 1643 |
* The set of modifiers |
1644 |
* @param mn |
|
1645 |
* The module name |
|
1646 |
* |
|
1647 |
* @return This builder |
|
1648 |
* |
|
1649 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1650 |
* If the module name is {@code null}, is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1651 |
* name, or is equal to the module name that this builder |
36511 | 1652 |
* was initialized to build |
1653 |
* @throws IllegalStateException |
|
1654 |
* If the dependence on the module has already been declared |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1655 |
* or this builder is for an automatic module |
36511 | 1656 |
*/ |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1657 |
public Builder requires(Set<Requires.Modifier> ms, String mn) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1658 |
if (strict) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1659 |
mn = requireModuleName(mn); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1660 |
return requires(new Requires(ms, mn, null, null)); |
36511 | 1661 |
} |
1662 |
||
1663 |
/** |
|
1664 |
* Adds a dependence on a module with an empty set of modifiers. |
|
1665 |
* |
|
1666 |
* @param mn |
|
1667 |
* The module name |
|
1668 |
* |
|
1669 |
* @return This builder |
|
1670 |
* |
|
1671 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1672 |
* If the module name is {@code null}, is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1673 |
* name, or is equal to the module name that this builder |
36511 | 1674 |
* was initialized to build |
1675 |
* @throws IllegalStateException |
|
1676 |
* If the dependence on the module has already been declared |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1677 |
* or this builder is for an automatic module |
36511 | 1678 |
*/ |
1679 |
public Builder requires(String mn) { |
|
1680 |
return requires(EnumSet.noneOf(Requires.Modifier.class), mn); |
|
1681 |
} |
|
1682 |
||
1683 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1684 |
* Adds an exported package. |
36511 | 1685 |
* |
1686 |
* @param e |
|
1687 |
* The export |
|
1688 |
* |
|
1689 |
* @return This builder |
|
1690 |
* |
|
1691 |
* @throws IllegalStateException |
|
47004 | 1692 |
* If the {@link Exports#source() package} is already declared as |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1693 |
* exported or this builder is for an automatic module |
36511 | 1694 |
*/ |
1695 |
public Builder exports(Exports e) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1696 |
if (automatic) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1697 |
throw new IllegalStateException("Automatic modules cannot declare" |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1698 |
+ " exported packages"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1699 |
} |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1700 |
String source = e.source(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1701 |
if (exports.containsKey(source)) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1702 |
throw new IllegalStateException("Exported package " + source |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1703 |
+ " already declared"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1704 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1705 |
exports.put(source, e); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1706 |
packages.add(source); |
36511 | 1707 |
return this; |
1708 |
} |
|
1709 |
||
1710 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1711 |
* Adds an exported package with the given (and possibly empty) set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1712 |
* modifiers. The package is exported to a set of target modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1713 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1714 |
* @param ms |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1715 |
* The set of modifiers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1716 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1717 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1718 |
* @param targets |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1719 |
* The set of target modules names |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1720 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1721 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1722 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1723 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1724 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1725 |
* package name, the set of target modules is empty, or the set |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1726 |
* of target modules contains a name that is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1727 |
* name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1728 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1729 |
* If the package is already declared as exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1730 |
* or this builder is for an automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1731 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1732 |
public Builder exports(Set<Exports.Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1733 |
String pn, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1734 |
Set<String> targets) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1735 |
{ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1736 |
Exports e = new Exports(ms, pn, targets); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1737 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1738 |
// check targets |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1739 |
targets = e.targets(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1740 |
if (targets.isEmpty()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1741 |
throw new IllegalArgumentException("Empty target set"); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1742 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1743 |
requirePackageName(e.source()); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1744 |
targets.stream().forEach(Checks::requireModuleName); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1745 |
} |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1746 |
return exports(e); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1747 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1748 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1749 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1750 |
* Adds an exported package with the given (and possibly empty) set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1751 |
* modifiers. The package is exported to all modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1752 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1753 |
* @param ms |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1754 |
* The set of modifiers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1755 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1756 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1757 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1758 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1759 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1760 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1761 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1762 |
* package name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1763 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1764 |
* If the package is already declared as exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1765 |
* or this builder is for an automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1766 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1767 |
public Builder exports(Set<Exports.Modifier> ms, String pn) { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1768 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1769 |
requirePackageName(pn); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1770 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1771 |
Exports e = new Exports(ms, pn, Collections.emptySet()); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1772 |
return exports(e); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1773 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1774 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1775 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1776 |
* Adds an exported package. The package is exported to a set of target |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1777 |
* modules. |
36511 | 1778 |
* |
1779 |
* @param pn |
|
1780 |
* The package name |
|
1781 |
* @param targets |
|
1782 |
* The set of target modules names |
|
1783 |
* |
|
1784 |
* @return This builder |
|
1785 |
* |
|
1786 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1787 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1788 |
* package name, the set of target modules is empty, or the set |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1789 |
* of target modules contains a name that is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1790 |
* name |
36511 | 1791 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1792 |
* If the package is already declared as exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1793 |
* or this builder is for an automatic module |
36511 | 1794 |
*/ |
1795 |
public Builder exports(String pn, Set<String> targets) { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1796 |
return exports(Collections.emptySet(), pn, targets); |
36511 | 1797 |
} |
1798 |
||
1799 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1800 |
* Adds an exported package. The package is exported to all modules. |
36511 | 1801 |
* |
1802 |
* @param pn |
|
1803 |
* The package name |
|
1804 |
* |
|
1805 |
* @return This builder |
|
1806 |
* |
|
1807 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1808 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1809 |
* package name |
36511 | 1810 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1811 |
* If the package is already declared as exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1812 |
* or this builder is for an automatic module |
36511 | 1813 |
*/ |
1814 |
public Builder exports(String pn) { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1815 |
return exports(Collections.emptySet(), pn); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1816 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1817 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1818 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1819 |
* Adds an open package. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1820 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1821 |
* @param obj |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1822 |
* The {@code Opens} object |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1823 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1824 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1825 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1826 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1827 |
* If the package is already declared as open, or this is a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1828 |
* builder for an open module or automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1829 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1830 |
public Builder opens(Opens obj) { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1831 |
if (open || automatic) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1832 |
throw new IllegalStateException("Open or automatic modules cannot" |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1833 |
+ " declare open packages"); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1834 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1835 |
String source = obj.source(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1836 |
if (opens.containsKey(source)) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1837 |
throw new IllegalStateException("Open package " + source |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1838 |
+ " already declared"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1839 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1840 |
opens.put(source, obj); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1841 |
packages.add(source); |
36511 | 1842 |
return this; |
1843 |
} |
|
1844 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1845 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1846 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1847 |
* Adds an open package with the given (and possibly empty) set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1848 |
* modifiers. The package is open to a set of target modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1849 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1850 |
* @param ms |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1851 |
* The set of modifiers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1852 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1853 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1854 |
* @param targets |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1855 |
* The set of target modules names |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1856 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1857 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1858 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1859 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1860 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1861 |
* package name, the set of target modules is empty, or the set |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1862 |
* of target modules contains a name that is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1863 |
* name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1864 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1865 |
* If the package is already declared as open, or this is a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1866 |
* builder for an open module or automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1867 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1868 |
public Builder opens(Set<Opens.Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1869 |
String pn, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1870 |
Set<String> targets) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1871 |
{ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1872 |
Opens opens = new Opens(ms, pn, targets); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1873 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1874 |
// check targets |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1875 |
targets = opens.targets(); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1876 |
if (targets.isEmpty()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1877 |
throw new IllegalArgumentException("Empty target set"); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1878 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1879 |
requirePackageName(opens.source()); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1880 |
targets.stream().forEach(Checks::requireModuleName); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1881 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1882 |
return opens(opens); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1883 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1884 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1885 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1886 |
* Adds an open package with the given (and possibly empty) set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1887 |
* modifiers. The package is open to all modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1888 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1889 |
* @param ms |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1890 |
* The set of modifiers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1891 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1892 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1893 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1894 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1895 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1896 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1897 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1898 |
* package name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1899 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1900 |
* If the package is already declared as open, or this is a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1901 |
* builder for an open module or automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1902 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1903 |
public Builder opens(Set<Opens.Modifier> ms, String pn) { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1904 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1905 |
requirePackageName(pn); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1906 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1907 |
Opens e = new Opens(ms, pn, Collections.emptySet()); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1908 |
return opens(e); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1909 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1910 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1911 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1912 |
* Adds an open package. The package is open to a set of target modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1913 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1914 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1915 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1916 |
* @param targets |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1917 |
* The set of target modules names |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1918 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1919 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1920 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1921 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1922 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1923 |
* package name, the set of target modules is empty, or the set |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1924 |
* of target modules contains a name that is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1925 |
* name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1926 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1927 |
* If the package is already declared as open, or this is a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1928 |
* builder for an open module or automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1929 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1930 |
public Builder opens(String pn, Set<String> targets) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1931 |
return opens(Collections.emptySet(), pn, targets); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1932 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1933 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1934 |
/** |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1935 |
* Adds an open package. The package is open to all modules. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1936 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1937 |
* @param pn |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1938 |
* The package name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1939 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1940 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1941 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1942 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1943 |
* If the package name is {@code null} or is not a legal |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1944 |
* package name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1945 |
* @throws IllegalStateException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1946 |
* If the package is already declared as open, or this is a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1947 |
* builder for an open module or automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1948 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1949 |
public Builder opens(String pn) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1950 |
return opens(Collections.emptySet(), pn); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1951 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1952 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1953 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1954 |
* Adds a service dependence. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1955 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1956 |
* @param service |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1957 |
* The service type |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1958 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1959 |
* @return This builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1960 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1961 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1962 |
* If the service type is {@code null} or not a qualified name of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1963 |
* a class in a named package |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1964 |
* @throws IllegalStateException |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1965 |
* If a dependency on the service type has already been declared |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
1966 |
* or this is a builder for an automatic module |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1967 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1968 |
public Builder uses(String service) { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1969 |
if (automatic) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1970 |
throw new IllegalStateException("Automatic modules can not declare" |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1971 |
+ " service dependences"); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1972 |
if (uses.contains(requireServiceTypeName(service))) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1973 |
throw new IllegalStateException("Dependence upon service " |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1974 |
+ service + " already declared"); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1975 |
uses.add(service); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
1976 |
return this; |
36511 | 1977 |
} |
1978 |
||
1979 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1980 |
* Provides a service with one or more implementations. The package for |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1981 |
* each {@link Provides#providers provider} (or provider factory) is |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1982 |
* added to the module if not already added. |
36511 | 1983 |
* |
1984 |
* @param p |
|
1985 |
* The provides |
|
1986 |
* |
|
1987 |
* @return This builder |
|
1988 |
* |
|
1989 |
* @throws IllegalStateException |
|
1990 |
* If the providers for the service type have already been |
|
1991 |
* declared |
|
1992 |
*/ |
|
1993 |
public Builder provides(Provides p) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1994 |
String service = p.service(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1995 |
if (provides.containsKey(service)) |
36511 | 1996 |
throw new IllegalStateException("Providers of service " |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1997 |
+ service + " already declared"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1998 |
provides.put(service, p); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
1999 |
p.providers().forEach(name -> packages.add(packageName(name))); |
36511 | 2000 |
return this; |
2001 |
} |
|
2002 |
||
2003 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2004 |
* Provides implementations of a service. The package for each provider |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2005 |
* (or provider factory) is added to the module if not already added. |
36511 | 2006 |
* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2007 |
* @param service |
36511 | 2008 |
* The service type |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2009 |
* @param providers |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2010 |
* The list of provider or provider factory class names |
36511 | 2011 |
* |
2012 |
* @return This builder |
|
2013 |
* |
|
2014 |
* @throws IllegalArgumentException |
|
2015 |
* If the service type or any of the provider class names is |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2016 |
* {@code null} or not a qualified name of a class in a named |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2017 |
* package, or the list of provider class names is empty |
36511 | 2018 |
* @throws IllegalStateException |
2019 |
* If the providers for the service type have already been |
|
2020 |
* declared |
|
2021 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2022 |
public Builder provides(String service, List<String> providers) { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2023 |
Provides p = new Provides(service, providers); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2024 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2025 |
// check providers after the set has been copied. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2026 |
List<String> providerNames = p.providers(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2027 |
if (providerNames.isEmpty()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2028 |
throw new IllegalArgumentException("Empty providers set"); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2029 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2030 |
requireServiceTypeName(p.service()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2031 |
providerNames.forEach(Checks::requireServiceProviderName); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2032 |
} else { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2033 |
// Disallow service/providers in unnamed package |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2034 |
String pn = packageName(service); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2035 |
if (pn.isEmpty()) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2036 |
throw new IllegalArgumentException(service |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2037 |
+ ": unnamed package"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2038 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2039 |
for (String name : providerNames) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2040 |
pn = packageName(name); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2041 |
if (pn.isEmpty()) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2042 |
throw new IllegalArgumentException(name |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2043 |
+ ": unnamed package"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2044 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2045 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2046 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2047 |
return provides(p); |
36511 | 2048 |
} |
2049 |
||
2050 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2051 |
* Adds packages to the module. All packages in the set of package names |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2052 |
* that are not in the module are added to module. |
36511 | 2053 |
* |
2054 |
* @param pns |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2055 |
* The (possibly empty) set of package names |
36511 | 2056 |
* |
2057 |
* @return This builder |
|
2058 |
* |
|
2059 |
* @throws IllegalArgumentException |
|
2060 |
* If any of the package names is {@code null} or is not a |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2061 |
* legal package name |
36511 | 2062 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2063 |
public Builder packages(Set<String> pns) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2064 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2065 |
pns = new HashSet<>(pns); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2066 |
pns.forEach(Checks::requirePackageName); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2067 |
} |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2068 |
this.packages.addAll(pns); |
36511 | 2069 |
return this; |
2070 |
} |
|
2071 |
||
2072 |
/** |
|
2073 |
* Sets the module version. |
|
2074 |
* |
|
2075 |
* @param v |
|
2076 |
* The version |
|
2077 |
* |
|
2078 |
* @return This builder |
|
2079 |
*/ |
|
2080 |
public Builder version(Version v) { |
|
2081 |
version = requireNonNull(v); |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2082 |
rawVersionString = null; |
36511 | 2083 |
return this; |
2084 |
} |
|
2085 |
||
2086 |
/** |
|
2087 |
* Sets the module version. |
|
2088 |
* |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2089 |
* @param vs |
36511 | 2090 |
* The version string to parse |
2091 |
* |
|
2092 |
* @return This builder |
|
2093 |
* |
|
2094 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2095 |
* If {@code vs} is {@code null} or cannot be parsed as a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2096 |
* version string |
36511 | 2097 |
* |
2098 |
* @see Version#parse(String) |
|
2099 |
*/ |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2100 |
public Builder version(String vs) { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2101 |
try { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2102 |
version = Version.parse(vs); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2103 |
rawVersionString = null; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2104 |
} catch (IllegalArgumentException e) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2105 |
if (strict) throw e; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2106 |
version = null; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2107 |
rawVersionString = vs; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2108 |
} |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2109 |
return this; |
36511 | 2110 |
} |
2111 |
||
2112 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2113 |
* Sets the module main class. The package for the main class is added |
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
2114 |
* to the module if not already added. In other words, this method is |
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
2115 |
* equivalent to first invoking this builder's {@link #packages(Set) |
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
2116 |
* packages} method to add the package name of the main class. |
36511 | 2117 |
* |
2118 |
* @param mc |
|
2119 |
* The module main class |
|
2120 |
* |
|
2121 |
* @return This builder |
|
2122 |
* |
|
2123 |
* @throws IllegalArgumentException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2124 |
* If {@code mainClass} is {@code null} or not a qualified |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2125 |
* name of a class in a named package |
36511 | 2126 |
*/ |
2127 |
public Builder mainClass(String mc) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2128 |
String pn; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2129 |
if (strict) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2130 |
mc = requireQualifiedClassName("main class name", mc); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2131 |
pn = packageName(mc); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2132 |
assert !pn.isEmpty(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2133 |
} else { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2134 |
// Disallow main class in unnamed package |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2135 |
pn = packageName(mc); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2136 |
if (pn.isEmpty()) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2137 |
throw new IllegalArgumentException(mc + ": unnamed package"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2138 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2139 |
} |
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44359
diff
changeset
|
2140 |
packages.add(pn); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2141 |
mainClass = mc; |
36511 | 2142 |
return this; |
2143 |
} |
|
2144 |
||
2145 |
/** |
|
2146 |
* Builds and returns a {@code ModuleDescriptor} from its components. |
|
2147 |
* |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2148 |
* <p> The module will require "{@code java.base}" even if the dependence |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2149 |
* has not been declared (the exception is when building a module named |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2150 |
* "{@code java.base}" as it cannot require itself). The dependence on |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2151 |
* "{@code java.base}" will have the {@link |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2152 |
* java.lang.module.ModuleDescriptor.Requires.Modifier#MANDATED MANDATED} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2153 |
* modifier if the dependence was not declared. </p> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2154 |
* |
36511 | 2155 |
* @return The module descriptor |
2156 |
*/ |
|
2157 |
public ModuleDescriptor build() { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2158 |
Set<Requires> requires = new HashSet<>(this.requires.values()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2159 |
Set<Exports> exports = new HashSet<>(this.exports.values()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2160 |
Set<Opens> opens = new HashSet<>(this.opens.values()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2161 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2162 |
// add dependency on java.base |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2163 |
if (strict |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2164 |
&& !name.equals("java.base") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2165 |
&& !this.requires.containsKey("java.base")) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2166 |
requires.add(new Requires(Set.of(Requires.Modifier.MANDATED), |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2167 |
"java.base", |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2168 |
null, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2169 |
null)); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2170 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2171 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2172 |
Set<Provides> provides = new HashSet<>(this.provides.values()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2173 |
|
36511 | 2174 |
return new ModuleDescriptor(name, |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2175 |
version, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2176 |
rawVersionString, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2177 |
modifiers, |
36511 | 2178 |
requires, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2179 |
exports, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2180 |
opens, |
36511 | 2181 |
uses, |
2182 |
provides, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2183 |
packages, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2184 |
mainClass); |
36511 | 2185 |
} |
2186 |
||
2187 |
} |
|
2188 |
||
2189 |
/** |
|
2190 |
* Compares this module descriptor to another. |
|
2191 |
* |
|
2192 |
* <p> Two {@code ModuleDescriptor} objects are compared by comparing their |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2193 |
* module names lexicographically. Where the module names are equal then the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2194 |
* module versions are compared. When comparing the module versions then a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2195 |
* module descriptor with a version is considered to succeed a module |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2196 |
* descriptor that does not have a version. If both versions are {@linkplain |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2197 |
* Version#parse(String) unparseable} then the {@linkplain #rawVersion() |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2198 |
* raw version strings} are compared lexicographically. Where the module names |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2199 |
* are equal and the versions are equal (or not present in both), then the |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2200 |
* set of modifiers are compared. Sets of modifiers are compared by comparing |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2201 |
* a <em>binary value</em> computed for each set. If a modifier is present |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2202 |
* in the set then the bit at the position of its ordinal is {@code 1} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2203 |
* in the binary value, otherwise {@code 0}. If the two set of modifiers |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2204 |
* are also equal then the other components of the module descriptors are |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2205 |
* compared in a manner that is consistent with {@code equals}. </p> |
36511 | 2206 |
* |
2207 |
* @param that |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2208 |
* The module descriptor to compare |
36511 | 2209 |
* |
2210 |
* @return A negative integer, zero, or a positive integer if this module |
|
2211 |
* descriptor is less than, equal to, or greater than the given |
|
2212 |
* module descriptor |
|
2213 |
*/ |
|
2214 |
@Override |
|
2215 |
public int compareTo(ModuleDescriptor that) { |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2216 |
if (this == that) return 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2217 |
|
36511 | 2218 |
int c = this.name().compareTo(that.name()); |
2219 |
if (c != 0) return c; |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2220 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2221 |
c = compare(this.version, that.version); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2222 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2223 |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2224 |
c = compare(this.rawVersionString, that.rawVersionString); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2225 |
if (c != 0) return c; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2226 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2227 |
long v1 = modsValue(this.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2228 |
long v2 = modsValue(that.modifiers()); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2229 |
c = Long.compare(v1, v2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2230 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2231 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2232 |
c = compare(this.requires, that.requires); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2233 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2234 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2235 |
c = compare(this.packages, that.packages); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2236 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2237 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2238 |
c = compare(this.exports, that.exports); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2239 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2240 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2241 |
c = compare(this.opens, that.opens); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2242 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2243 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2244 |
c = compare(this.uses, that.uses); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2245 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2246 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2247 |
c = compare(this.provides, that.provides); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2248 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2249 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2250 |
c = compare(this.mainClass, that.mainClass); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2251 |
if (c != 0) return c; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2252 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2253 |
return 0; |
36511 | 2254 |
} |
2255 |
||
2256 |
/** |
|
2257 |
* Tests this module descriptor for equality with the given object. |
|
2258 |
* |
|
2259 |
* <p> If the given object is not a {@code ModuleDescriptor} then this |
|
2260 |
* method returns {@code false}. Two module descriptors are equal if each |
|
2261 |
* of their corresponding components is equal. </p> |
|
2262 |
* |
|
2263 |
* <p> This method satisfies the general contract of the {@link |
|
2264 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
2265 |
* |
|
2266 |
* @param ob |
|
2267 |
* the object to which this object is to be compared |
|
2268 |
* |
|
2269 |
* @return {@code true} if, and only if, the given object is a module |
|
2270 |
* descriptor that is equal to this module descriptor |
|
2271 |
*/ |
|
2272 |
@Override |
|
2273 |
public boolean equals(Object ob) { |
|
2274 |
if (ob == this) |
|
2275 |
return true; |
|
2276 |
if (!(ob instanceof ModuleDescriptor)) |
|
2277 |
return false; |
|
2278 |
ModuleDescriptor that = (ModuleDescriptor)ob; |
|
2279 |
return (name.equals(that.name) |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2280 |
&& modifiers.equals(that.modifiers) |
36511 | 2281 |
&& requires.equals(that.requires) |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2282 |
&& Objects.equals(packages, that.packages) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2283 |
&& exports.equals(that.exports) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2284 |
&& opens.equals(that.opens) |
36511 | 2285 |
&& uses.equals(that.uses) |
2286 |
&& provides.equals(that.provides) |
|
2287 |
&& Objects.equals(version, that.version) |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2288 |
&& Objects.equals(rawVersionString, that.rawVersionString) |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2289 |
&& Objects.equals(mainClass, that.mainClass)); |
36511 | 2290 |
} |
2291 |
||
2292 |
/** |
|
2293 |
* Computes a hash code for this module descriptor. |
|
2294 |
* |
|
2295 |
* <p> The hash code is based upon the components of the module descriptor, |
|
2296 |
* and satisfies the general contract of the {@link Object#hashCode |
|
2297 |
* Object.hashCode} method. </p> |
|
2298 |
* |
|
2299 |
* @return The hash-code value for this module descriptor |
|
2300 |
*/ |
|
2301 |
@Override |
|
2302 |
public int hashCode() { |
|
2303 |
int hc = hash; |
|
2304 |
if (hc == 0) { |
|
2305 |
hc = name.hashCode(); |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2306 |
hc = hc * 43 + Objects.hashCode(modifiers); |
36511 | 2307 |
hc = hc * 43 + requires.hashCode(); |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2308 |
hc = hc * 43 + Objects.hashCode(packages); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2309 |
hc = hc * 43 + exports.hashCode(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2310 |
hc = hc * 43 + opens.hashCode(); |
36511 | 2311 |
hc = hc * 43 + uses.hashCode(); |
2312 |
hc = hc * 43 + provides.hashCode(); |
|
2313 |
hc = hc * 43 + Objects.hashCode(version); |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2314 |
hc = hc * 43 + Objects.hashCode(rawVersionString); |
36511 | 2315 |
hc = hc * 43 + Objects.hashCode(mainClass); |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2316 |
if (hc == 0) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2317 |
hc = -1; |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2318 |
hash = hc; |
36511 | 2319 |
} |
2320 |
return hc; |
|
2321 |
} |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2322 |
private transient int hash; // cached hash code |
36511 | 2323 |
|
2324 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2325 |
* <p> Returns a string describing the module. </p> |
36511 | 2326 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2327 |
* @return A string describing the module |
36511 | 2328 |
*/ |
2329 |
@Override |
|
2330 |
public String toString() { |
|
2331 |
StringBuilder sb = new StringBuilder(); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2332 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2333 |
if (isOpen()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2334 |
sb.append("open "); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2335 |
sb.append("module { name: ").append(toNameAndVersion()); |
36511 | 2336 |
if (!requires.isEmpty()) |
2337 |
sb.append(", ").append(requires); |
|
2338 |
if (!uses.isEmpty()) |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2339 |
sb.append(", uses: ").append(uses); |
36511 | 2340 |
if (!exports.isEmpty()) |
2341 |
sb.append(", exports: ").append(exports); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2342 |
if (!opens.isEmpty()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2343 |
sb.append(", opens: ").append(opens); |
36511 | 2344 |
if (!provides.isEmpty()) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2345 |
sb.append(", provides: ").append(provides); |
36511 | 2346 |
} |
2347 |
sb.append(" }"); |
|
2348 |
return sb.toString(); |
|
2349 |
} |
|
2350 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2351 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2352 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2353 |
* Instantiates a builder to build a module descriptor. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2354 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2355 |
* @param name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2356 |
* The module name |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2357 |
* @param ms |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2358 |
* The set of module modifiers |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2359 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2360 |
* @return A new builder |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2361 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2362 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2363 |
* If the module name is {@code null} or is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2364 |
* name, or the set of modifiers contains {@link |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2365 |
* Modifier#AUTOMATIC AUTOMATIC} with other modifiers |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2366 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2367 |
public static Builder newModule(String name, Set<Modifier> ms) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2368 |
Set<Modifier> mods = new HashSet<>(ms); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2369 |
if (mods.contains(Modifier.AUTOMATIC) && mods.size() > 1) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2370 |
throw new IllegalArgumentException("AUTOMATIC cannot be used with" |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2371 |
+ " other modifiers"); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2372 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2373 |
return new Builder(name, true, mods); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2374 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2375 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2376 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2377 |
* Instantiates a builder to build a module descriptor for a <em>normal</em> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2378 |
* module. This method is equivalent to invoking {@link #newModule(String,Set) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2379 |
* newModule} with an empty set of {@link ModuleDescriptor.Modifier modifiers}. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2380 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2381 |
* @param name |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2382 |
* The module name |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2383 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2384 |
* @return A new builder |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2385 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2386 |
* @throws IllegalArgumentException |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2387 |
* If the module name is {@code null} or is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2388 |
* name |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2389 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2390 |
public static Builder newModule(String name) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2391 |
return new Builder(name, true, Set.of()); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2392 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2393 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2394 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2395 |
* Instantiates a builder to build a module descriptor for an open module. |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2396 |
* This method is equivalent to invoking {@link #newModule(String,Set) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2397 |
* newModule} with the {@link ModuleDescriptor.Modifier#OPEN OPEN} modifier. |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2398 |
* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2399 |
* <p> The builder for an open module cannot be used to declare any open |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2400 |
* packages. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2401 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2402 |
* @param name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2403 |
* The module name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2404 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2405 |
* @return A new builder that builds an open module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2406 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2407 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2408 |
* If the module name is {@code null} or is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2409 |
* name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2410 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2411 |
public static Builder newOpenModule(String name) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2412 |
return new Builder(name, true, Set.of(Modifier.OPEN)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2413 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2414 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2415 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2416 |
* Instantiates a builder to build a module descriptor for an automatic |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2417 |
* module. This method is equivalent to invoking {@link #newModule(String,Set) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2418 |
* newModule} with the {@link ModuleDescriptor.Modifier#AUTOMATIC AUTOMATIC} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2419 |
* modifier. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2420 |
* |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2421 |
* <p> The builder for an automatic module cannot be used to declare module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2422 |
* or service dependences. It also cannot be used to declare any exported |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2423 |
* or open packages. </p> |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2424 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2425 |
* @param name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2426 |
* The module name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2427 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2428 |
* @return A new builder that builds an automatic module |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2429 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2430 |
* @throws IllegalArgumentException |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2431 |
* If the module name is {@code null} or is not a legal module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2432 |
* name |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2433 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2434 |
* @see ModuleFinder#of(Path[]) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2435 |
*/ |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2436 |
public static Builder newAutomaticModule(String name) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2437 |
return new Builder(name, true, Set.of(Modifier.AUTOMATIC)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2438 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2439 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2440 |
|
36511 | 2441 |
/** |
2442 |
* Reads the binary form of a module declaration from an input stream |
|
2443 |
* as a module descriptor. |
|
2444 |
* |
|
2445 |
* <p> If the descriptor encoded in the input stream does not indicate a |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2446 |
* set of packages in the module then the {@code packageFinder} will be |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2447 |
* invoked. The set of packages that the {@code packageFinder} returns |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2448 |
* must include all the packages that the module exports, opens, as well |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2449 |
* as the packages of the service implementations that the module provides, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2450 |
* and the package of the main class (if the module has a main class). If |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2451 |
* the {@code packageFinder} throws an {@link UncheckedIOException} then |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2452 |
* {@link IOException} cause will be re-thrown. </p> |
36511 | 2453 |
* |
2454 |
* <p> If there are bytes following the module descriptor then it is |
|
2455 |
* implementation specific as to whether those bytes are read, ignored, |
|
2456 |
* or reported as an {@code InvalidModuleDescriptorException}. If this |
|
2457 |
* method fails with an {@code InvalidModuleDescriptorException} or {@code |
|
2458 |
* IOException} then it may do so after some, but not all, bytes have |
|
2459 |
* been read from the input stream. It is strongly recommended that the |
|
2460 |
* stream be promptly closed and discarded if an exception occurs. </p> |
|
2461 |
* |
|
2462 |
* @apiNote The {@code packageFinder} parameter is for use when reading |
|
2463 |
* module descriptors from legacy module-artifact formats that do not |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2464 |
* record the set of packages in the descriptor itself. |
36511 | 2465 |
* |
2466 |
* @param in |
|
2467 |
* The input stream |
|
2468 |
* @param packageFinder |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2469 |
* A supplier that can produce the set of packages |
36511 | 2470 |
* |
2471 |
* @return The module descriptor |
|
2472 |
* |
|
2473 |
* @throws InvalidModuleDescriptorException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2474 |
* If an invalid module descriptor is detected or the set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2475 |
* packages returned by the {@code packageFinder} does not include |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2476 |
* all of the packages obtained from the module descriptor |
36511 | 2477 |
* @throws IOException |
2478 |
* If an I/O error occurs reading from the input stream or {@code |
|
2479 |
* UncheckedIOException} is thrown by the package finder |
|
2480 |
*/ |
|
2481 |
public static ModuleDescriptor read(InputStream in, |
|
2482 |
Supplier<Set<String>> packageFinder) |
|
2483 |
throws IOException |
|
2484 |
{ |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2485 |
return ModuleInfo.read(in, requireNonNull(packageFinder)).descriptor(); |
36511 | 2486 |
} |
2487 |
||
2488 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2489 |
* Reads the binary form of a module declaration from an input stream as a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2490 |
* module descriptor. This method works exactly as specified by the 2-arg |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2491 |
* {@link #read(InputStream,Supplier) read} method with the exception that |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2492 |
* a packager finder is not used to find additional packages when the |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2493 |
* module descriptor read from the stream does not indicate the set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2494 |
* packages. |
36511 | 2495 |
* |
2496 |
* @param in |
|
2497 |
* The input stream |
|
2498 |
* |
|
2499 |
* @return The module descriptor |
|
2500 |
* |
|
2501 |
* @throws InvalidModuleDescriptorException |
|
2502 |
* If an invalid module descriptor is detected |
|
2503 |
* @throws IOException |
|
2504 |
* If an I/O error occurs reading from the input stream |
|
2505 |
*/ |
|
2506 |
public static ModuleDescriptor read(InputStream in) throws IOException { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2507 |
return ModuleInfo.read(in, null).descriptor(); |
36511 | 2508 |
} |
2509 |
||
2510 |
/** |
|
2511 |
* Reads the binary form of a module declaration from a byte buffer |
|
2512 |
* as a module descriptor. |
|
2513 |
* |
|
2514 |
* <p> If the descriptor encoded in the byte buffer does not indicate a |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2515 |
* set of packages in the module then the {@code packageFinder} will be |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2516 |
* invoked. The set of packages that the {@code packageFinder} returns |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2517 |
* must include all the packages that the module exports, opens, as well |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2518 |
* as the packages of the service implementations that the module provides, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2519 |
* and the package of the main class (if the module has a main class). If |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2520 |
* the {@code packageFinder} throws an {@link UncheckedIOException} then |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2521 |
* {@link IOException} cause will be re-thrown. </p> |
36511 | 2522 |
* |
2523 |
* <p> The module descriptor is read from the buffer stating at index |
|
2524 |
* {@code p}, where {@code p} is the buffer's {@link ByteBuffer#position() |
|
2525 |
* position} when this method is invoked. Upon return the buffer's position |
|
2526 |
* will be equal to {@code p + n} where {@code n} is the number of bytes |
|
2527 |
* read from the buffer. </p> |
|
2528 |
* |
|
2529 |
* <p> If there are bytes following the module descriptor then it is |
|
2530 |
* implementation specific as to whether those bytes are read, ignored, |
|
2531 |
* or reported as an {@code InvalidModuleDescriptorException}. If this |
|
2532 |
* method fails with an {@code InvalidModuleDescriptorException} then it |
|
2533 |
* may do so after some, but not all, bytes have been read. </p> |
|
2534 |
* |
|
2535 |
* @apiNote The {@code packageFinder} parameter is for use when reading |
|
2536 |
* module descriptors from legacy module-artifact formats that do not |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2537 |
* record the set of packages in the descriptor itself. |
36511 | 2538 |
* |
2539 |
* @param bb |
|
2540 |
* The byte buffer |
|
2541 |
* @param packageFinder |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2542 |
* A supplier that can produce the set of packages |
36511 | 2543 |
* |
2544 |
* @return The module descriptor |
|
2545 |
* |
|
2546 |
* @throws InvalidModuleDescriptorException |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2547 |
* If an invalid module descriptor is detected or the set of |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2548 |
* packages returned by the {@code packageFinder} does not include |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2549 |
* all of the packages obtained from the module descriptor |
36511 | 2550 |
*/ |
2551 |
public static ModuleDescriptor read(ByteBuffer bb, |
|
2552 |
Supplier<Set<String>> packageFinder) |
|
2553 |
{ |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2554 |
return ModuleInfo.read(bb, requireNonNull(packageFinder)).descriptor(); |
36511 | 2555 |
} |
2556 |
||
2557 |
/** |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2558 |
* Reads the binary form of a module declaration from a byte buffer as a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2559 |
* module descriptor. This method works exactly as specified by the 2-arg |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2560 |
* {@link #read(ByteBuffer,Supplier) read} method with the exception that a |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2561 |
* packager finder is not used to find additional packages when the module |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2562 |
* descriptor encoded in the buffer does not indicate the set of packages. |
36511 | 2563 |
* |
2564 |
* @param bb |
|
2565 |
* The byte buffer |
|
2566 |
* |
|
2567 |
* @return The module descriptor |
|
2568 |
* |
|
2569 |
* @throws InvalidModuleDescriptorException |
|
2570 |
* If an invalid module descriptor is detected |
|
2571 |
*/ |
|
2572 |
public static ModuleDescriptor read(ByteBuffer bb) { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2573 |
return ModuleInfo.read(bb, null).descriptor(); |
36511 | 2574 |
} |
2575 |
||
2576 |
private static <K,V> Map<K,V> emptyOrUnmodifiableMap(Map<K,V> map) { |
|
2577 |
if (map.isEmpty()) { |
|
2578 |
return Collections.emptyMap(); |
|
2579 |
} else if (map.size() == 1) { |
|
2580 |
Map.Entry<K, V> entry = map.entrySet().iterator().next(); |
|
2581 |
return Collections.singletonMap(entry.getKey(), entry.getValue()); |
|
2582 |
} else { |
|
2583 |
return Collections.unmodifiableMap(map); |
|
2584 |
} |
|
2585 |
} |
|
2586 |
||
2587 |
private static <T> Set<T> emptyOrUnmodifiableSet(Set<T> set) { |
|
2588 |
if (set.isEmpty()) { |
|
2589 |
return Collections.emptySet(); |
|
2590 |
} else if (set.size() == 1) { |
|
2591 |
return Collections.singleton(set.iterator().next()); |
|
2592 |
} else { |
|
2593 |
return Collections.unmodifiableSet(set); |
|
2594 |
} |
|
2595 |
} |
|
2596 |
||
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2597 |
private static String packageName(String cn) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2598 |
int index = cn.lastIndexOf('.'); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2599 |
return (index == -1) ? "" : cn.substring(0, index); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2600 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2601 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2602 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2603 |
* Returns a string containing the given set of modifiers and label. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2604 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2605 |
private static <M> String toString(Set<M> mods, String what) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2606 |
return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase()), |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2607 |
Stream.of(what))) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2608 |
.collect(Collectors.joining(" ")); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2609 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2610 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2611 |
private static <T extends Object & Comparable<? super T>> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2612 |
int compare(T obj1, T obj2) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2613 |
if (obj1 != null) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2614 |
return (obj2 != null) ? obj1.compareTo(obj2) : 1; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2615 |
} else { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2616 |
return (obj2 == null) ? 0 : -1; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2617 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2618 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2619 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2620 |
/** |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2621 |
* Compares two sets of {@code Comparable} objects. |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2622 |
*/ |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2623 |
@SuppressWarnings("unchecked") |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2624 |
private static <T extends Object & Comparable<? super T>> |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2625 |
int compare(Set<T> s1, Set<T> s2) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2626 |
T[] a1 = (T[]) s1.toArray(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2627 |
T[] a2 = (T[]) s2.toArray(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2628 |
Arrays.sort(a1); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2629 |
Arrays.sort(a2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2630 |
return Arrays.compare(a1, a2); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2631 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2632 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2633 |
private static <E extends Enum<E>> long modsValue(Set<E> set) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2634 |
long value = 0; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2635 |
for (Enum<E> e : set) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2636 |
value += 1 << e.ordinal(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2637 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2638 |
return value; |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2639 |
} |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2640 |
|
36511 | 2641 |
static { |
2642 |
/** |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2643 |
* Setup the shared secret to allow code in other packages access |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2644 |
* private package methods in java.lang.module. |
36511 | 2645 |
*/ |
2646 |
jdk.internal.misc.SharedSecrets |
|
2647 |
.setJavaLangModuleAccess(new jdk.internal.misc.JavaLangModuleAccess() { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2648 |
@Override |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2649 |
public Builder newModuleBuilder(String mn, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2650 |
boolean strict, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2651 |
Set<ModuleDescriptor.Modifier> modifiers) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2652 |
return new Builder(mn, strict, modifiers); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2653 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2654 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2655 |
@Override |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2656 |
public Set<String> packages(ModuleDescriptor.Builder builder) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2657 |
return builder.packages(); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2658 |
} |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2659 |
|
36511 | 2660 |
@Override |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2661 |
public void requires(ModuleDescriptor.Builder builder, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2662 |
Set<Requires.Modifier> ms, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2663 |
String mn, |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2664 |
String rawCompiledVersion) { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
2665 |
builder.requires(ms, mn, rawCompiledVersion); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2666 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2667 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2668 |
@Override |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2669 |
public Requires newRequires(Set<Requires.Modifier> ms, String mn, Version v) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2670 |
return new Requires(ms, mn, v, true); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2671 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2672 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2673 |
@Override |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2674 |
public Exports newExports(Set<Exports.Modifier> ms, String source) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2675 |
return new Exports(ms, source, Collections.emptySet(), true); |
36511 | 2676 |
} |
2677 |
||
2678 |
@Override |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2679 |
public Exports newExports(Set<Exports.Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2680 |
String source, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2681 |
Set<String> targets) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2682 |
return new Exports(ms, source, targets, true); |
36511 | 2683 |
} |
2684 |
||
2685 |
@Override |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2686 |
public Opens newOpens(Set<Opens.Modifier> ms, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2687 |
String source, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2688 |
Set<String> targets) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2689 |
return new Opens(ms, source, targets, true); |
36511 | 2690 |
} |
2691 |
||
2692 |
@Override |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2693 |
public Opens newOpens(Set<Opens.Modifier> ms, String source) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2694 |
return new Opens(ms, source, Collections.emptySet(), true); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2695 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2696 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2697 |
@Override |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2698 |
public Provides newProvides(String service, List<String> providers) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2699 |
return new Provides(service, providers, true); |
36511 | 2700 |
} |
2701 |
||
2702 |
@Override |
|
2703 |
public ModuleDescriptor newModuleDescriptor(String name, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2704 |
Version version, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2705 |
Set<ModuleDescriptor.Modifier> modifiers, |
36511 | 2706 |
Set<Requires> requires, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2707 |
Set<Exports> exports, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2708 |
Set<Opens> opens, |
38888
dd584fbea6a2
8159334: ModuleDescriptor retains overlapping sets for all and concealed packages
redestad
parents:
37880
diff
changeset
|
2709 |
Set<String> uses, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2710 |
Set<Provides> provides, |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2711 |
Set<String> packages, |
36511 | 2712 |
String mainClass, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2713 |
int hashCode) { |
36511 | 2714 |
return new ModuleDescriptor(name, |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2715 |
version, |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2716 |
modifiers, |
36511 | 2717 |
requires, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2718 |
exports, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2719 |
opens, |
36511 | 2720 |
uses, |
2721 |
provides, |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
2722 |
packages, |
36511 | 2723 |
mainClass, |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2724 |
hashCode, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2725 |
false); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2726 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2727 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41817
diff
changeset
|
2728 |
@Override |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2729 |
public Configuration resolveAndBind(ModuleFinder finder, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2730 |
Collection<String> roots, |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2731 |
PrintStream traceOutput) |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2732 |
{ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2733 |
return Configuration.resolveAndBind(finder, roots, traceOutput); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2734 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2735 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2736 |
@Override |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2737 |
public Configuration newConfiguration(ModuleFinder finder, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2738 |
Map<String, Set<String>> graph) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45004
diff
changeset
|
2739 |
return new Configuration(finder, graph); |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
2740 |
} |
36511 | 2741 |
}); |
2742 |
} |
|
2743 |
||
2744 |
} |