author | alanb |
Tue, 19 Nov 2019 11:35:29 +0000 | |
changeset 59133 | 580fb715b29d |
parent 52814 | abccada595dd |
permissions | -rw-r--r-- |
42703 | 1 |
/* |
59133
580fb715b29d
8233922: Service binding augments module graph with observable incubator modules
alanb
parents:
52814
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
42703 | 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 |
package jdk.tools.jlink.internal.plugins; |
|
26 |
||
27 |
import java.io.ByteArrayInputStream; |
|
28 |
import java.io.ByteArrayOutputStream; |
|
29 |
import java.io.IOException; |
|
30 |
import java.io.InputStream; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
31 |
import java.lang.module.Configuration; |
42703 | 32 |
import java.lang.module.ModuleDescriptor; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
33 |
import java.lang.module.ModuleDescriptor.Exports; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
34 |
import java.lang.module.ModuleDescriptor.Opens; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
35 |
import java.lang.module.ModuleDescriptor.Provides; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
36 |
import java.lang.module.ModuleDescriptor.Requires; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
37 |
import java.lang.module.ModuleDescriptor.Version; |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
38 |
import java.lang.module.ModuleFinder; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
39 |
import java.lang.module.ModuleReader; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
40 |
import java.lang.module.ModuleReference; |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
41 |
import java.lang.module.ResolvedModule; |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
42 |
import java.net.URI; |
42703 | 43 |
import java.util.ArrayList; |
44 |
import java.util.Collection; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
45 |
import java.util.Collections; |
42703 | 46 |
import java.util.EnumSet; |
47 |
import java.util.HashMap; |
|
42770
d363e7c3584a
8171400: Move checking of duplicate packages in the boot layer to link time
redestad
parents:
42752
diff
changeset
|
48 |
import java.util.HashSet; |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
49 |
import java.util.LinkedHashMap; |
42703 | 50 |
import java.util.List; |
51 |
import java.util.Map; |
|
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
52 |
import java.util.Objects; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
53 |
import java.util.Optional; |
42703 | 54 |
import java.util.Set; |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
55 |
import java.util.TreeMap; |
42703 | 56 |
import java.util.TreeSet; |
57 |
import java.util.function.IntSupplier; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
58 |
import java.util.function.Supplier; |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
59 |
import java.util.stream.Collectors; |
42703 | 60 |
|
61 |
import jdk.internal.module.Checks; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
62 |
import jdk.internal.module.DefaultRoots; |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
63 |
import jdk.internal.module.IllegalAccessMaps; |
59133
580fb715b29d
8233922: Service binding augments module graph with observable incubator modules
alanb
parents:
52814
diff
changeset
|
64 |
import jdk.internal.module.Modules; |
42703 | 65 |
import jdk.internal.module.ModuleHashes; |
66 |
import jdk.internal.module.ModuleInfo.Attributes; |
|
67 |
import jdk.internal.module.ModuleInfoExtender; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
68 |
import jdk.internal.module.ModuleReferenceImpl; |
42703 | 69 |
import jdk.internal.module.ModuleResolution; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
70 |
import jdk.internal.module.ModuleTarget; |
47489 | 71 |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
72 |
import jdk.internal.org.objectweb.asm.ClassReader; |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
73 |
import jdk.internal.org.objectweb.asm.ClassVisitor; |
42703 | 74 |
import jdk.internal.org.objectweb.asm.ClassWriter; |
75 |
import jdk.internal.org.objectweb.asm.MethodVisitor; |
|
47489 | 76 |
import jdk.internal.org.objectweb.asm.ModuleVisitor; |
42703 | 77 |
import jdk.internal.org.objectweb.asm.Opcodes; |
78 |
import static jdk.internal.org.objectweb.asm.Opcodes.*; |
|
79 |
||
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
80 |
import jdk.tools.jlink.internal.ModuleSorter; |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
81 |
import jdk.tools.jlink.plugin.Plugin; |
42703 | 82 |
import jdk.tools.jlink.plugin.PluginException; |
83 |
import jdk.tools.jlink.plugin.ResourcePool; |
|
84 |
import jdk.tools.jlink.plugin.ResourcePoolBuilder; |
|
85 |
import jdk.tools.jlink.plugin.ResourcePoolEntry; |
|
86 |
||
87 |
/** |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
88 |
* Jlink plugin to reconstitute module descriptors and other attributes for system |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
89 |
* modules. The plugin generates implementations of SystemModules to avoid parsing |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
90 |
* module-info.class files at startup. It also generates SystemModulesMap to return |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
91 |
* the SystemModules implementation for a specific initial module. |
42703 | 92 |
* |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
93 |
* As a side effect, the plugin adds the ModulePackages class file attribute to the |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
94 |
* module-info.class files that don't have the attribute. |
42703 | 95 |
* |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
96 |
* @see jdk.internal.module.SystemModuleFinders |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
97 |
* @see jdk.internal.module.SystemModules |
42703 | 98 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
99 |
|
42703 | 100 |
public final class SystemModulesPlugin implements Plugin { |
101 |
private static final String NAME = "system-modules"; |
|
102 |
private static final String DESCRIPTION = |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
103 |
PluginsResourceBundle.getDescription(NAME); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
104 |
private static final String SYSTEM_MODULES_MAP_CLASS = |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
105 |
"jdk/internal/module/SystemModulesMap"; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
106 |
private static final String SYSTEM_MODULES_CLASS_PREFIX = |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
107 |
"jdk/internal/module/SystemModules$"; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
108 |
private static final String ALL_SYSTEM_MODULES_CLASS = |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
109 |
SYSTEM_MODULES_CLASS_PREFIX + "all"; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
110 |
private static final String DEFAULT_SYSTEM_MODULES_CLASS = |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
111 |
SYSTEM_MODULES_CLASS_PREFIX + "default"; |
42703 | 112 |
|
113 |
private boolean enabled; |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
114 |
|
42703 | 115 |
public SystemModulesPlugin() { |
116 |
this.enabled = true; |
|
117 |
} |
|
118 |
||
119 |
@Override |
|
120 |
public String getName() { |
|
121 |
return NAME; |
|
122 |
} |
|
123 |
||
124 |
@Override |
|
125 |
public String getDescription() { |
|
126 |
return DESCRIPTION; |
|
127 |
} |
|
128 |
||
129 |
@Override |
|
130 |
public Set<State> getState() { |
|
131 |
return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL) |
|
132 |
: EnumSet.of(State.DISABLED); |
|
133 |
} |
|
134 |
||
135 |
@Override |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
136 |
public boolean hasArguments() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
137 |
return true; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
138 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
139 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
140 |
@Override |
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
141 |
public String getArgumentsDescription() { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
142 |
return PluginsResourceBundle.getArgument(NAME); |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
143 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
144 |
|
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
145 |
@Override |
42703 | 146 |
public void configure(Map<String, String> config) { |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
147 |
String arg = config.get(NAME); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
148 |
if (arg != null) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
149 |
throw new IllegalArgumentException(NAME + ": " + arg); |
42703 | 150 |
} |
151 |
} |
|
152 |
||
153 |
@Override |
|
154 |
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { |
|
155 |
if (!enabled) { |
|
156 |
throw new PluginException(NAME + " was set"); |
|
157 |
} |
|
158 |
||
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
159 |
// validate, transform (if needed), and add the module-info.class files |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
160 |
List<ModuleInfo> moduleInfos = transformModuleInfos(in, out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
161 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
162 |
// generate and add the SystemModuleMap and SystemModules classes |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
163 |
Set<String> generated = genSystemModulesClasses(moduleInfos, out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
164 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
165 |
// pass through all other resources |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
166 |
in.entries() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
167 |
.filter(data -> !data.path().endsWith("/module-info.class") |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
168 |
&& !generated.contains(data.path())) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
169 |
.forEach(data -> out.add(data)); |
42703 | 170 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
171 |
return out.build(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
172 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
173 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
174 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
175 |
* Validates and transforms the module-info.class files in the modules, adding |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
176 |
* the ModulePackages class file attribute if needed. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
177 |
* |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
178 |
* @return the list of ModuleInfo objects, the first element is java.base |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
179 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
180 |
List<ModuleInfo> transformModuleInfos(ResourcePool in, ResourcePoolBuilder out) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
181 |
List<ModuleInfo> moduleInfos = new ArrayList<>(); |
42703 | 182 |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
183 |
// Sort modules in the topological order so that java.base is always first. |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
184 |
new ModuleSorter(in.moduleView()).sorted().forEach(module -> { |
42703 | 185 |
ResourcePoolEntry data = module.findEntry("module-info.class").orElseThrow( |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
186 |
// automatic modules not supported |
42703 | 187 |
() -> new PluginException("module-info.class not found for " + |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
188 |
module.name() + " module") |
42703 | 189 |
); |
190 |
||
191 |
assert module.name().equals(data.moduleName()); |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
192 |
|
42703 | 193 |
try { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
194 |
byte[] content = data.contentBytes(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
195 |
Set<String> packages = module.packages(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
196 |
ModuleInfo moduleInfo = new ModuleInfo(content, packages); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
197 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
198 |
// link-time validation |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
199 |
moduleInfo.validateNames(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
200 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
201 |
// check if any exported or open package is not present |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
202 |
moduleInfo.validatePackages(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
203 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
204 |
// module-info.class may be overridden to add ModulePackages |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
205 |
if (moduleInfo.shouldRewrite()) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
206 |
data = data.copyWithContent(moduleInfo.getBytes()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
207 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
208 |
moduleInfos.add(moduleInfo); |
42703 | 209 |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
210 |
// add resource pool entry |
42703 | 211 |
out.add(data); |
212 |
} catch (IOException e) { |
|
213 |
throw new PluginException(e); |
|
214 |
} |
|
215 |
}); |
|
216 |
||
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
217 |
return moduleInfos; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
218 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
219 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
220 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
221 |
* Generates the SystemModules classes (at least one) and the SystemModulesMap |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
222 |
* class to map initial modules to a SystemModules class. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
223 |
* |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
224 |
* @return the resource names of the resources added to the pool |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
225 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
226 |
private Set<String> genSystemModulesClasses(List<ModuleInfo> moduleInfos, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
227 |
ResourcePoolBuilder out) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
228 |
int moduleCount = moduleInfos.size(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
229 |
ModuleFinder finder = finderOf(moduleInfos); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
230 |
assert finder.findAll().size() == moduleCount; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
231 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
232 |
// map of initial module name to SystemModules class name |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
233 |
Map<String, String> map = new LinkedHashMap<>(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
234 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
235 |
// the names of resources written to the pool |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
236 |
Set<String> generated = new HashSet<>(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
237 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
238 |
// generate the SystemModules implementation to reconstitute all modules |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
239 |
Set<String> allModuleNames = moduleInfos.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
240 |
.map(ModuleInfo::moduleName) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
241 |
.collect(Collectors.toSet()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
242 |
String rn = genSystemModulesClass(moduleInfos, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
243 |
resolve(finder, allModuleNames), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
244 |
ALL_SYSTEM_MODULES_CLASS, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
245 |
out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
246 |
generated.add(rn); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
247 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
248 |
// generate, if needed, a SystemModules class to reconstitute the modules |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
249 |
// needed for the case that the initial module is the unnamed module. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
250 |
String defaultSystemModulesClassName; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
251 |
Configuration cf = resolve(finder, DefaultRoots.compute(finder)); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
252 |
if (cf.modules().size() == moduleCount) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
253 |
// all modules are resolved so no need to generate a class |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
254 |
defaultSystemModulesClassName = ALL_SYSTEM_MODULES_CLASS; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
255 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
256 |
defaultSystemModulesClassName = DEFAULT_SYSTEM_MODULES_CLASS; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
257 |
rn = genSystemModulesClass(sublist(moduleInfos, cf), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
258 |
cf, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
259 |
defaultSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
260 |
out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
261 |
generated.add(rn); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
262 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
263 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
264 |
// Generate a SystemModules class for each module with a main class |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
265 |
int suffix = 0; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
266 |
for (ModuleInfo mi : moduleInfos) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
267 |
if (mi.descriptor().mainClass().isPresent()) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
268 |
String moduleName = mi.moduleName(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
269 |
cf = resolve(finder, Set.of(moduleName)); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
270 |
if (cf.modules().size() == moduleCount) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
271 |
// resolves all modules so no need to generate a class |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
272 |
map.put(moduleName, ALL_SYSTEM_MODULES_CLASS); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
273 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
274 |
String cn = SYSTEM_MODULES_CLASS_PREFIX + (suffix++); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
275 |
rn = genSystemModulesClass(sublist(moduleInfos, cf), cf, cn, out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
276 |
map.put(moduleName, cn); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
277 |
generated.add(rn); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
278 |
} |
42703 | 279 |
} |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
280 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
281 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
282 |
// generate SystemModulesMap |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
283 |
rn = genSystemModulesMapClass(ALL_SYSTEM_MODULES_CLASS, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
284 |
defaultSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
285 |
map, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
286 |
out); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
287 |
generated.add(rn); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
288 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
289 |
// return the resource names of the generated classes |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
290 |
return generated; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
291 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
292 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
293 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
294 |
* Resolves a collection of root modules, with service binding, to create |
59133
580fb715b29d
8233922: Service binding augments module graph with observable incubator modules
alanb
parents:
52814
diff
changeset
|
295 |
* a Configuration for the boot layer. |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
296 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
297 |
private Configuration resolve(ModuleFinder finder, Set<String> roots) { |
59133
580fb715b29d
8233922: Service binding augments module graph with observable incubator modules
alanb
parents:
52814
diff
changeset
|
298 |
return Modules.newBootLayerConfiguration(finder, roots, null); |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
299 |
} |
42703 | 300 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
301 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
302 |
* Returns the list of ModuleInfo objects that correspond to the modules in |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
303 |
* the given configuration. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
304 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
305 |
private List<ModuleInfo> sublist(List<ModuleInfo> moduleInfos, Configuration cf) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
306 |
Set<String> names = cf.modules() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
307 |
.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
308 |
.map(ResolvedModule::name) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
309 |
.collect(Collectors.toSet()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
310 |
return moduleInfos.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
311 |
.filter(mi -> names.contains(mi.moduleName())) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
312 |
.collect(Collectors.toList()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
313 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
314 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
315 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
316 |
* Generate a SystemModules implementation class and add it as a resource. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
317 |
* |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
318 |
* @return the name of the class resource added to the pool |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
319 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
320 |
private String genSystemModulesClass(List<ModuleInfo> moduleInfos, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
321 |
Configuration cf, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
322 |
String className, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
323 |
ResourcePoolBuilder out) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
324 |
SystemModulesClassGenerator generator |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
325 |
= new SystemModulesClassGenerator(className, moduleInfos); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
326 |
byte[] bytes = generator.getClassWriter(cf).toByteArray(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
327 |
String rn = "/java.base/" + className + ".class"; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
328 |
ResourcePoolEntry e = ResourcePoolEntry.create(rn, bytes); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
329 |
out.add(e); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
330 |
return rn; |
42703 | 331 |
} |
332 |
||
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
333 |
static class ModuleInfo { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
334 |
private final ByteArrayInputStream bais; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
335 |
private final Attributes attrs; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
336 |
private final Set<String> packages; |
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
337 |
private final boolean addModulePackages; |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
338 |
private ModuleDescriptor descriptor; // may be different that the original one |
42703 | 339 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
340 |
ModuleInfo(byte[] bytes, Set<String> packages) throws IOException { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
341 |
this.bais = new ByteArrayInputStream(bytes); |
42703 | 342 |
this.packages = packages; |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
343 |
this.attrs = jdk.internal.module.ModuleInfo.read(bais, null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
344 |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
345 |
// If ModulePackages attribute is present, the packages from this |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
346 |
// module descriptor returns the packages in that attribute. |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
347 |
// If it's not present, ModuleDescriptor::packages only contains |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
348 |
// the exported and open packages from module-info.class |
42703 | 349 |
this.descriptor = attrs.descriptor(); |
350 |
if (descriptor.isAutomatic()) { |
|
351 |
throw new InternalError("linking automatic module is not supported"); |
|
352 |
} |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
353 |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
354 |
// add ModulePackages attribute if this module contains some packages |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
355 |
// and ModulePackages is not present |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
356 |
this.addModulePackages = packages.size() > 0 && !hasModulePackages(); |
42703 | 357 |
} |
358 |
||
359 |
String moduleName() { |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
360 |
return attrs.descriptor().name(); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
361 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
362 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
363 |
ModuleDescriptor descriptor() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
364 |
return descriptor; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
365 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
366 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
367 |
Set<String> packages() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
368 |
return packages; |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
369 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
370 |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
371 |
ModuleTarget target() { |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
372 |
return attrs.target(); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
373 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
374 |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
375 |
ModuleHashes recordedHashes() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
376 |
return attrs.recordedHashes(); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
377 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
378 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
379 |
ModuleResolution moduleResolution() { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
380 |
return attrs.moduleResolution(); |
42703 | 381 |
} |
382 |
||
383 |
/** |
|
384 |
* Validates names in ModuleDescriptor |
|
385 |
*/ |
|
386 |
void validateNames() { |
|
387 |
Checks.requireModuleName(descriptor.name()); |
|
388 |
for (Requires req : descriptor.requires()) { |
|
389 |
Checks.requireModuleName(req.name()); |
|
390 |
} |
|
391 |
for (Exports e : descriptor.exports()) { |
|
392 |
Checks.requirePackageName(e.source()); |
|
393 |
if (e.isQualified()) |
|
394 |
e.targets().forEach(Checks::requireModuleName); |
|
395 |
} |
|
396 |
for (Opens opens : descriptor.opens()) { |
|
397 |
Checks.requirePackageName(opens.source()); |
|
398 |
if (opens.isQualified()) |
|
399 |
opens.targets().forEach(Checks::requireModuleName); |
|
400 |
} |
|
401 |
for (Provides provides : descriptor.provides()) { |
|
402 |
Checks.requireServiceTypeName(provides.service()); |
|
403 |
provides.providers().forEach(Checks::requireServiceProviderName); |
|
404 |
} |
|
405 |
for (String service : descriptor.uses()) { |
|
406 |
Checks.requireServiceTypeName(service); |
|
407 |
} |
|
408 |
for (String pn : descriptor.packages()) { |
|
409 |
Checks.requirePackageName(pn); |
|
410 |
} |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
411 |
for (String pn : packages) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
412 |
Checks.requirePackageName(pn); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
413 |
} |
42703 | 414 |
} |
415 |
||
416 |
/** |
|
417 |
* Validates if exported and open packages are present |
|
418 |
*/ |
|
419 |
void validatePackages() { |
|
420 |
Set<String> nonExistPackages = new TreeSet<>(); |
|
421 |
descriptor.exports().stream() |
|
422 |
.map(Exports::source) |
|
423 |
.filter(pn -> !packages.contains(pn)) |
|
424 |
.forEach(nonExistPackages::add); |
|
425 |
||
426 |
descriptor.opens().stream() |
|
427 |
.map(Opens::source) |
|
428 |
.filter(pn -> !packages.contains(pn)) |
|
429 |
.forEach(nonExistPackages::add); |
|
430 |
||
431 |
if (!nonExistPackages.isEmpty()) { |
|
432 |
throw new PluginException("Packages that are exported or open in " |
|
433 |
+ descriptor.name() + " are not present: " + nonExistPackages); |
|
434 |
} |
|
435 |
} |
|
436 |
||
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
437 |
boolean hasModulePackages() throws IOException { |
47489 | 438 |
Set<String> packages = new HashSet<>(); |
52515 | 439 |
ClassVisitor cv = new ClassVisitor(Opcodes.ASM7) { |
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
440 |
@Override |
47489 | 441 |
public ModuleVisitor visitModule(String name, |
442 |
int flags, |
|
443 |
String version) { |
|
52515 | 444 |
return new ModuleVisitor(Opcodes.ASM7) { |
47489 | 445 |
public void visitPackage(String pn) { |
446 |
packages.add(pn); |
|
447 |
} |
|
448 |
}; |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
449 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
450 |
}; |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
451 |
|
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
452 |
try (InputStream in = getInputStream()) { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
453 |
// parse module-info.class |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
454 |
ClassReader cr = new ClassReader(in); |
47489 | 455 |
cr.accept(cv, 0); |
456 |
return packages.size() > 0; |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
457 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
458 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
459 |
|
42703 | 460 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
461 |
* Returns true if module-info.class should be rewritten to add the |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
462 |
* ModulePackages attribute. |
42703 | 463 |
*/ |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
464 |
boolean shouldRewrite() { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
465 |
return addModulePackages; |
42703 | 466 |
} |
467 |
||
468 |
/** |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
469 |
* Returns the bytes for the (possibly updated) module-info.class. |
42703 | 470 |
*/ |
471 |
byte[] getBytes() throws IOException { |
|
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
472 |
try (InputStream in = getInputStream()) { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
473 |
if (shouldRewrite()) { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
474 |
ModuleInfoRewriter rewriter = new ModuleInfoRewriter(in); |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
475 |
if (addModulePackages) { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
476 |
rewriter.addModulePackages(packages); |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
477 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
478 |
// rewritten module descriptor |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
479 |
byte[] bytes = rewriter.getBytes(); |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
480 |
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
481 |
this.descriptor = ModuleDescriptor.read(bais); |
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
482 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
483 |
return bytes; |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
484 |
} else { |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
485 |
return in.readAllBytes(); |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
486 |
} |
42703 | 487 |
} |
488 |
} |
|
489 |
||
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
490 |
/* |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
491 |
* Returns the input stream of the module-info.class |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
492 |
*/ |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
493 |
InputStream getInputStream() { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
494 |
bais.reset(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
495 |
return bais; |
43732
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
496 |
} |
358d327a8220
8174740: RuntimeException: Module m's descriptor returns inconsistent package set
mchung
parents:
43712
diff
changeset
|
497 |
|
42703 | 498 |
class ModuleInfoRewriter extends ByteArrayOutputStream { |
499 |
final ModuleInfoExtender extender; |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
500 |
ModuleInfoRewriter(InputStream in) { |
42703 | 501 |
this.extender = ModuleInfoExtender.newExtender(in); |
502 |
} |
|
503 |
||
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
504 |
void addModulePackages(Set<String> packages) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
505 |
// Add ModulePackages attribute |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
506 |
if (packages.size() > 0) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
507 |
extender.packages(packages); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
508 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
509 |
} |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
510 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
511 |
byte[] getBytes() throws IOException { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
512 |
extender.write(this); |
42703 | 513 |
return buf; |
514 |
} |
|
515 |
} |
|
516 |
} |
|
517 |
||
518 |
/** |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
519 |
* Generates a SystemModules class to reconstitute the ModuleDescriptor |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
520 |
* and other attributes of system modules. |
42703 | 521 |
*/ |
522 |
static class SystemModulesClassGenerator { |
|
523 |
private static final String MODULE_DESCRIPTOR_BUILDER = |
|
524 |
"jdk/internal/module/Builder"; |
|
525 |
private static final String MODULE_DESCRIPTOR_ARRAY_SIGNATURE = |
|
526 |
"[Ljava/lang/module/ModuleDescriptor;"; |
|
527 |
private static final String REQUIRES_MODIFIER_CLASSNAME = |
|
528 |
"java/lang/module/ModuleDescriptor$Requires$Modifier"; |
|
529 |
private static final String EXPORTS_MODIFIER_CLASSNAME = |
|
530 |
"java/lang/module/ModuleDescriptor$Exports$Modifier"; |
|
531 |
private static final String OPENS_MODIFIER_CLASSNAME = |
|
532 |
"java/lang/module/ModuleDescriptor$Opens$Modifier"; |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
533 |
private static final String MODULE_TARGET_CLASSNAME = |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
534 |
"jdk/internal/module/ModuleTarget"; |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
535 |
private static final String MODULE_TARGET_ARRAY_SIGNATURE = |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
536 |
"[Ljdk/internal/module/ModuleTarget;"; |
42703 | 537 |
private static final String MODULE_HASHES_ARRAY_SIGNATURE = |
538 |
"[Ljdk/internal/module/ModuleHashes;"; |
|
539 |
private static final String MODULE_RESOLUTION_CLASSNAME = |
|
540 |
"jdk/internal/module/ModuleResolution"; |
|
541 |
private static final String MODULE_RESOLUTIONS_ARRAY_SIGNATURE = |
|
542 |
"[Ljdk/internal/module/ModuleResolution;"; |
|
543 |
||
544 |
private static final int MAX_LOCAL_VARS = 256; |
|
545 |
||
546 |
private final int BUILDER_VAR = 0; |
|
547 |
private final int MD_VAR = 1; // variable for ModuleDescriptor |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
548 |
private final int MT_VAR = 1; // variable for ModuleTarget |
42703 | 549 |
private final int MH_VAR = 1; // variable for ModuleHashes |
550 |
private int nextLocalVar = 2; // index to next local variable |
|
551 |
||
552 |
// Method visitor for generating the SystemModules::modules() method |
|
553 |
private MethodVisitor mv; |
|
554 |
||
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
555 |
// name of class to generate |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
556 |
private final String className; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
557 |
|
42703 | 558 |
// list of all ModuleDescriptorBuilders, invoked in turn when building. |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
559 |
private final List<ModuleInfo> moduleInfos; |
42703 | 560 |
|
561 |
// A builder to create one single Set instance for a given set of |
|
562 |
// names or modifiers to reduce the footprint |
|
563 |
// e.g. target modules of qualified exports |
|
564 |
private final DedupSetBuilder dedupSetBuilder |
|
565 |
= new DedupSetBuilder(this::getNextLocalVar); |
|
566 |
||
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
567 |
public SystemModulesClassGenerator(String className, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
568 |
List<ModuleInfo> moduleInfos) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
569 |
this.className = className; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
570 |
this.moduleInfos = moduleInfos; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
571 |
moduleInfos.forEach(mi -> dedups(mi.descriptor())); |
42703 | 572 |
} |
573 |
||
574 |
private int getNextLocalVar() { |
|
575 |
return nextLocalVar++; |
|
576 |
} |
|
577 |
||
578 |
/* |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
579 |
* Adds the given ModuleDescriptor to the system module list. |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
580 |
* It performs link-time validation and prepares mapping from various |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
581 |
* Sets to SetBuilders to emit an optimized number of sets during build. |
42703 | 582 |
*/ |
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
583 |
private void dedups(ModuleDescriptor md) { |
42703 | 584 |
// exports |
585 |
for (Exports e : md.exports()) { |
|
586 |
dedupSetBuilder.stringSet(e.targets()); |
|
587 |
dedupSetBuilder.exportsModifiers(e.modifiers()); |
|
588 |
} |
|
589 |
||
590 |
// opens |
|
591 |
for (Opens opens : md.opens()) { |
|
592 |
dedupSetBuilder.stringSet(opens.targets()); |
|
593 |
dedupSetBuilder.opensModifiers(opens.modifiers()); |
|
594 |
} |
|
595 |
||
596 |
// requires |
|
597 |
for (Requires r : md.requires()) { |
|
598 |
dedupSetBuilder.requiresModifiers(r.modifiers()); |
|
599 |
} |
|
600 |
||
601 |
// uses |
|
602 |
dedupSetBuilder.stringSet(md.uses()); |
|
603 |
} |
|
604 |
||
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
605 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
606 |
* Generate SystemModules class |
42703 | 607 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
608 |
public ClassWriter getClassWriter(Configuration cf) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
609 |
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
610 |
+ ClassWriter.COMPUTE_FRAMES); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
611 |
cw.visit(Opcodes.V1_8, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
612 |
ACC_FINAL+ACC_SUPER, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
613 |
className, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
614 |
null, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
615 |
"java/lang/Object", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
616 |
new String[] { "jdk/internal/module/SystemModules" }); |
42703 | 617 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
618 |
// generate <init> |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
619 |
genConstructor(cw); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
620 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
621 |
// generate hasSplitPackages |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
622 |
genHasSplitPackages(cw); |
42703 | 623 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
624 |
// generate hasIncubatorModules |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
625 |
genIncubatorModules(cw); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
626 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
627 |
// generate moduleDescriptors |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
628 |
genModuleDescriptorsMethod(cw); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
629 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
630 |
// generate moduleTargets |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
631 |
genModuleTargetsMethod(cw); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
632 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
633 |
// generate moduleHashes |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
634 |
genModuleHashesMethod(cw); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
635 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
636 |
// generate moduleResolutions |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
637 |
genModuleResolutionsMethod(cw); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
638 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
639 |
// generate moduleReads |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
640 |
genModuleReads(cw, cf); |
42703 | 641 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
642 |
// generate concealedPackagesToOpen and exportedPackagesToOpen |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
643 |
genXXXPackagesToOpenMethods(cw); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
644 |
|
42703 | 645 |
return cw; |
646 |
} |
|
647 |
||
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
648 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
649 |
* Generate byteccode for no-arg constructor |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
650 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
651 |
private void genConstructor(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
652 |
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
653 |
mv.visitVarInsn(ALOAD, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
654 |
mv.visitMethodInsn(INVOKESPECIAL, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
655 |
"java/lang/Object", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
656 |
"<init>", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
657 |
"()V", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
658 |
false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
659 |
mv.visitInsn(RETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
660 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
661 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
662 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
663 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
664 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
665 |
* Generate bytecode for hasSplitPackages method |
42703 | 666 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
667 |
private void genHasSplitPackages(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
668 |
boolean distinct = moduleInfos.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
669 |
.map(ModuleInfo::packages) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
670 |
.flatMap(Set::stream) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
671 |
.allMatch(new HashSet<>()::add); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
672 |
boolean hasSplitPackages = !distinct; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
673 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
674 |
mv = cw.visitMethod(ACC_PUBLIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
675 |
"hasSplitPackages", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
676 |
"()Z", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
677 |
"()Z", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
678 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
679 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
680 |
if (hasSplitPackages) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
681 |
mv.visitInsn(ICONST_1); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
682 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
683 |
mv.visitInsn(ICONST_0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
684 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
685 |
mv.visitInsn(IRETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
686 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
687 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
688 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
689 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
690 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
691 |
* Generate bytecode for hasIncubatorModules method |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
692 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
693 |
private void genIncubatorModules(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
694 |
boolean hasIncubatorModules = moduleInfos.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
695 |
.map(ModuleInfo::moduleResolution) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
696 |
.filter(mres -> (mres != null && mres.hasIncubatingWarning())) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
697 |
.findFirst() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
698 |
.isPresent(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
699 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
700 |
mv = cw.visitMethod(ACC_PUBLIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
701 |
"hasIncubatorModules", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
702 |
"()Z", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
703 |
"()Z", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
704 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
705 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
706 |
if (hasIncubatorModules) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
707 |
mv.visitInsn(ICONST_1); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
708 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
709 |
mv.visitInsn(ICONST_0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
710 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
711 |
mv.visitInsn(IRETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
712 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
713 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
714 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
715 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
716 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
717 |
* Generate bytecode for moduleDescriptors method |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
718 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
719 |
private void genModuleDescriptorsMethod(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
720 |
this.mv = cw.visitMethod(ACC_PUBLIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
721 |
"moduleDescriptors", |
42703 | 722 |
"()" + MODULE_DESCRIPTOR_ARRAY_SIGNATURE, |
723 |
"()" + MODULE_DESCRIPTOR_ARRAY_SIGNATURE, |
|
724 |
null); |
|
725 |
mv.visitCode(); |
|
726 |
pushInt(mv, moduleInfos.size()); |
|
727 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor"); |
|
728 |
mv.visitVarInsn(ASTORE, MD_VAR); |
|
729 |
||
730 |
for (int index = 0; index < moduleInfos.size(); index++) { |
|
731 |
ModuleInfo minfo = moduleInfos.get(index); |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
732 |
new ModuleDescriptorBuilder(minfo.descriptor(), |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
733 |
minfo.packages(), |
42703 | 734 |
index).build(); |
735 |
} |
|
736 |
mv.visitVarInsn(ALOAD, MD_VAR); |
|
737 |
mv.visitInsn(ARETURN); |
|
738 |
mv.visitMaxs(0, 0); |
|
739 |
mv.visitEnd(); |
|
740 |
} |
|
741 |
||
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
742 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
743 |
* Generate bytecode for moduleTargets method |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
744 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
745 |
private void genModuleTargetsMethod(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
746 |
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
747 |
"moduleTargets", |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
748 |
"()" + MODULE_TARGET_ARRAY_SIGNATURE, |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
749 |
"()" + MODULE_TARGET_ARRAY_SIGNATURE, |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
750 |
null); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
751 |
mv.visitCode(); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
752 |
pushInt(mv, moduleInfos.size()); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
753 |
mv.visitTypeInsn(ANEWARRAY, MODULE_TARGET_CLASSNAME); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
754 |
mv.visitVarInsn(ASTORE, MT_VAR); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
755 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
756 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
757 |
// if java.base has a ModuleTarget attribute then generate the array |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
758 |
// with one element, all other elements will be null. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
759 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
760 |
ModuleInfo base = moduleInfos.get(0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
761 |
if (!base.moduleName().equals("java.base")) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
762 |
throw new InternalError("java.base should be first module in list"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
763 |
ModuleTarget target = base.target(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
764 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
765 |
int count; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
766 |
if (target != null && target.targetPlatform() != null) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
767 |
count = 1; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
768 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
769 |
count = moduleInfos.size(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
770 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
771 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
772 |
for (int index = 0; index < count; index++) { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
773 |
ModuleInfo minfo = moduleInfos.get(index); |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
774 |
if (minfo.target() != null) { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
775 |
mv.visitVarInsn(ALOAD, MT_VAR); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
776 |
pushInt(mv, index); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
777 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
778 |
// new ModuleTarget(String) |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
779 |
mv.visitTypeInsn(NEW, MODULE_TARGET_CLASSNAME); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
780 |
mv.visitInsn(DUP); |
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
781 |
mv.visitLdcInsn(minfo.target().targetPlatform()); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
782 |
mv.visitMethodInsn(INVOKESPECIAL, MODULE_TARGET_CLASSNAME, |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
783 |
"<init>", "(Ljava/lang/String;)V", false); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
784 |
|
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
785 |
mv.visitInsn(AASTORE); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
786 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
787 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
788 |
|
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
789 |
mv.visitVarInsn(ALOAD, MT_VAR); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
790 |
mv.visitInsn(ARETURN); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
791 |
mv.visitMaxs(0, 0); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
792 |
mv.visitEnd(); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
793 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
794 |
|
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
795 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
796 |
* Generate bytecode for moduleHashes method |
42703 | 797 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
798 |
private void genModuleHashesMethod(ClassWriter cw) { |
42703 | 799 |
MethodVisitor hmv = |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
800 |
cw.visitMethod(ACC_PUBLIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
801 |
"moduleHashes", |
42703 | 802 |
"()" + MODULE_HASHES_ARRAY_SIGNATURE, |
803 |
"()" + MODULE_HASHES_ARRAY_SIGNATURE, |
|
804 |
null); |
|
805 |
hmv.visitCode(); |
|
806 |
pushInt(hmv, moduleInfos.size()); |
|
807 |
hmv.visitTypeInsn(ANEWARRAY, "jdk/internal/module/ModuleHashes"); |
|
808 |
hmv.visitVarInsn(ASTORE, MH_VAR); |
|
809 |
||
810 |
for (int index = 0; index < moduleInfos.size(); index++) { |
|
811 |
ModuleInfo minfo = moduleInfos.get(index); |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
812 |
if (minfo.recordedHashes() != null) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
813 |
new ModuleHashesBuilder(minfo.recordedHashes(), |
42703 | 814 |
index, |
815 |
hmv).build(); |
|
816 |
} |
|
817 |
} |
|
818 |
||
819 |
hmv.visitVarInsn(ALOAD, MH_VAR); |
|
820 |
hmv.visitInsn(ARETURN); |
|
821 |
hmv.visitMaxs(0, 0); |
|
822 |
hmv.visitEnd(); |
|
823 |
} |
|
824 |
||
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
825 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
826 |
* Generate bytecode for moduleResolutions method |
42703 | 827 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
828 |
private void genModuleResolutionsMethod(ClassWriter cw) { |
42703 | 829 |
MethodVisitor mresmv = |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
830 |
cw.visitMethod(ACC_PUBLIC, |
42703 | 831 |
"moduleResolutions", |
832 |
"()" + MODULE_RESOLUTIONS_ARRAY_SIGNATURE, |
|
833 |
"()" + MODULE_RESOLUTIONS_ARRAY_SIGNATURE, |
|
834 |
null); |
|
835 |
mresmv.visitCode(); |
|
836 |
pushInt(mresmv, moduleInfos.size()); |
|
837 |
mresmv.visitTypeInsn(ANEWARRAY, MODULE_RESOLUTION_CLASSNAME); |
|
838 |
mresmv.visitVarInsn(ASTORE, 0); |
|
839 |
||
840 |
for (int index=0; index < moduleInfos.size(); index++) { |
|
841 |
ModuleInfo minfo = moduleInfos.get(index); |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
842 |
if (minfo.moduleResolution() != null) { |
42703 | 843 |
mresmv.visitVarInsn(ALOAD, 0); |
844 |
pushInt(mresmv, index); |
|
845 |
mresmv.visitTypeInsn(NEW, MODULE_RESOLUTION_CLASSNAME); |
|
846 |
mresmv.visitInsn(DUP); |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
847 |
mresmv.visitLdcInsn(minfo.moduleResolution().value()); |
42703 | 848 |
mresmv.visitMethodInsn(INVOKESPECIAL, |
849 |
MODULE_RESOLUTION_CLASSNAME, |
|
850 |
"<init>", |
|
851 |
"(I)V", false); |
|
852 |
mresmv.visitInsn(AASTORE); |
|
853 |
} |
|
854 |
} |
|
855 |
mresmv.visitVarInsn(ALOAD, 0); |
|
856 |
mresmv.visitInsn(ARETURN); |
|
857 |
mresmv.visitMaxs(0, 0); |
|
858 |
mresmv.visitEnd(); |
|
859 |
} |
|
860 |
||
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
861 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
862 |
* Generate bytecode for moduleReads method |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
863 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
864 |
private void genModuleReads(ClassWriter cw, Configuration cf) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
865 |
// module name -> names of modules that it reads |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
866 |
Map<String, Set<String>> map = cf.modules().stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
867 |
.collect(Collectors.toMap( |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
868 |
ResolvedModule::name, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
869 |
m -> m.reads().stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
870 |
.map(ResolvedModule::name) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
871 |
.collect(Collectors.toSet()))); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
872 |
generate(cw, "moduleReads", map, true); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
873 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
874 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
875 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
876 |
* Generate concealedPackagesToOpen and exportedPackagesToOpen methods. |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
877 |
*/ |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
878 |
private void genXXXPackagesToOpenMethods(ClassWriter cw) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
879 |
ModuleFinder finder = finderOf(moduleInfos); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
880 |
IllegalAccessMaps maps = IllegalAccessMaps.generate(finder); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
881 |
generate(cw, "concealedPackagesToOpen", maps.concealedPackagesToOpen(), false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
882 |
generate(cw, "exportedPackagesToOpen", maps.exportedPackagesToOpen(), false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
883 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
884 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
885 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
886 |
* Generate method to return {@code Map<String, Set<String>>}. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
887 |
* |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
888 |
* If {@code dedup} is true then the values are de-duplicated. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
889 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
890 |
private void generate(ClassWriter cw, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
891 |
String methodName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
892 |
Map<String, Set<String>> map, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
893 |
boolean dedup) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
894 |
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
895 |
methodName, |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
896 |
"()Ljava/util/Map;", |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
897 |
"()Ljava/util/Map;", |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
898 |
null); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
899 |
mv.visitCode(); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
900 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
901 |
// map of Set -> local |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
902 |
Map<Set<String>, Integer> locals; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
903 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
904 |
// generate code to create the sets that are duplicated |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
905 |
if (dedup) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
906 |
Collection<Set<String>> values = map.values(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
907 |
Set<Set<String>> duplicateSets = values.stream() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
908 |
.distinct() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
909 |
.filter(s -> Collections.frequency(values, s) > 1) |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
910 |
.collect(Collectors.toSet()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
911 |
locals = new HashMap<>(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
912 |
int index = 1; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
913 |
for (Set<String> s : duplicateSets) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
914 |
genImmutableSet(mv, s); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
915 |
mv.visitVarInsn(ASTORE, index); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
916 |
locals.put(s, index); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
917 |
if (++index >= MAX_LOCAL_VARS) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
918 |
break; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
919 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
920 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
921 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
922 |
locals = Map.of(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
923 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
924 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
925 |
// new Map$Entry[size] |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
926 |
pushInt(mv, map.size()); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
927 |
mv.visitTypeInsn(ANEWARRAY, "java/util/Map$Entry"); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
928 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
929 |
int index = 0; |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
930 |
for (var e : new TreeMap<>(map).entrySet()) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
931 |
String name = e.getKey(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
932 |
Set<String> s = e.getValue(); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
933 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
934 |
mv.visitInsn(DUP); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
935 |
pushInt(mv, index); |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
936 |
mv.visitLdcInsn(name); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
937 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
938 |
// if de-duplicated then load the local, otherwise generate code |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
939 |
Integer varIndex = locals.get(s); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
940 |
if (varIndex == null) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
941 |
genImmutableSet(mv, s); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
942 |
} else { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
943 |
mv.visitVarInsn(ALOAD, varIndex); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
944 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
945 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
946 |
String desc = "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;"; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
947 |
mv.visitMethodInsn(INVOKESTATIC, |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
948 |
"java/util/Map", |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
949 |
"entry", |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
950 |
desc, |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
951 |
true); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
952 |
mv.visitInsn(AASTORE); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
953 |
index++; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
954 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
955 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
956 |
// invoke Map.ofEntries(Map$Entry[]) |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
957 |
mv.visitMethodInsn(INVOKESTATIC, "java/util/Map", "ofEntries", |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
958 |
"([Ljava/util/Map$Entry;)Ljava/util/Map;", true); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
959 |
mv.visitInsn(ARETURN); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
960 |
mv.visitMaxs(0, 0); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
961 |
mv.visitEnd(); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
962 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
963 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
964 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
965 |
* Generate code to generate an immutable set. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
966 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
967 |
private void genImmutableSet(MethodVisitor mv, Set<String> set) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
968 |
int size = set.size(); |
42703 | 969 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
970 |
// use Set.of(Object[]) when there are more than 2 elements |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
971 |
// use Set.of(Object) or Set.of(Object, Object) when fewer |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
972 |
if (size > 2) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
973 |
pushInt(mv, size); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
974 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
975 |
int i = 0; |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
976 |
for (String element : sorted(set)) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
977 |
mv.visitInsn(DUP); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
978 |
pushInt(mv, i); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
979 |
mv.visitLdcInsn(element); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
980 |
mv.visitInsn(AASTORE); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
981 |
i++; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
982 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
983 |
mv.visitMethodInsn(INVOKESTATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
984 |
"java/util/Set", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
985 |
"of", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
986 |
"([Ljava/lang/Object;)Ljava/util/Set;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
987 |
true); |
42703 | 988 |
} else { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
989 |
StringBuilder sb = new StringBuilder("("); |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
990 |
for (String element : sorted(set)) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
991 |
mv.visitLdcInsn(element); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
992 |
sb.append("Ljava/lang/Object;"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
993 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
994 |
sb.append(")Ljava/util/Set;"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
995 |
mv.visitMethodInsn(INVOKESTATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
996 |
"java/util/Set", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
997 |
"of", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
998 |
sb.toString(), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
999 |
true); |
42703 | 1000 |
} |
1001 |
} |
|
1002 |
||
1003 |
class ModuleDescriptorBuilder { |
|
1004 |
static final String BUILDER_TYPE = "Ljdk/internal/module/Builder;"; |
|
1005 |
static final String EXPORTS_TYPE = |
|
1006 |
"Ljava/lang/module/ModuleDescriptor$Exports;"; |
|
1007 |
static final String OPENS_TYPE = |
|
1008 |
"Ljava/lang/module/ModuleDescriptor$Opens;"; |
|
1009 |
static final String PROVIDES_TYPE = |
|
1010 |
"Ljava/lang/module/ModuleDescriptor$Provides;"; |
|
1011 |
static final String REQUIRES_TYPE = |
|
1012 |
"Ljava/lang/module/ModuleDescriptor$Requires;"; |
|
1013 |
||
1014 |
// method signature for static Builder::newExports, newOpens, |
|
1015 |
// newProvides, newRequires methods |
|
1016 |
static final String EXPORTS_MODIFIER_SET_STRING_SET_SIG = |
|
1017 |
"(Ljava/util/Set;Ljava/lang/String;Ljava/util/Set;)" |
|
1018 |
+ EXPORTS_TYPE; |
|
1019 |
static final String EXPORTS_MODIFIER_SET_STRING_SIG = |
|
1020 |
"(Ljava/util/Set;Ljava/lang/String;)" + EXPORTS_TYPE; |
|
1021 |
static final String OPENS_MODIFIER_SET_STRING_SET_SIG = |
|
1022 |
"(Ljava/util/Set;Ljava/lang/String;Ljava/util/Set;)" |
|
1023 |
+ OPENS_TYPE; |
|
1024 |
static final String OPENS_MODIFIER_SET_STRING_SIG = |
|
1025 |
"(Ljava/util/Set;Ljava/lang/String;)" + OPENS_TYPE; |
|
1026 |
static final String PROVIDES_STRING_LIST_SIG = |
|
1027 |
"(Ljava/lang/String;Ljava/util/List;)" + PROVIDES_TYPE; |
|
1028 |
static final String REQUIRES_SET_STRING_SIG = |
|
1029 |
"(Ljava/util/Set;Ljava/lang/String;)" + REQUIRES_TYPE; |
|
1030 |
static final String REQUIRES_SET_STRING_STRING_SIG = |
|
1031 |
"(Ljava/util/Set;Ljava/lang/String;Ljava/lang/String;)" + REQUIRES_TYPE; |
|
1032 |
||
1033 |
// method signature for Builder instance methods that |
|
1034 |
// return this Builder instance |
|
1035 |
static final String EXPORTS_ARRAY_SIG = |
|
1036 |
"([" + EXPORTS_TYPE + ")" + BUILDER_TYPE; |
|
1037 |
static final String OPENS_ARRAY_SIG = |
|
1038 |
"([" + OPENS_TYPE + ")" + BUILDER_TYPE; |
|
1039 |
static final String PROVIDES_ARRAY_SIG = |
|
1040 |
"([" + PROVIDES_TYPE + ")" + BUILDER_TYPE; |
|
1041 |
static final String REQUIRES_ARRAY_SIG = |
|
1042 |
"([" + REQUIRES_TYPE + ")" + BUILDER_TYPE; |
|
1043 |
static final String SET_SIG = "(Ljava/util/Set;)" + BUILDER_TYPE; |
|
1044 |
static final String STRING_SIG = "(Ljava/lang/String;)" + BUILDER_TYPE; |
|
1045 |
static final String BOOLEAN_SIG = "(Z)" + BUILDER_TYPE; |
|
1046 |
||
1047 |
final ModuleDescriptor md; |
|
1048 |
final Set<String> packages; |
|
1049 |
final int index; |
|
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43732
diff
changeset
|
1050 |
|
42703 | 1051 |
ModuleDescriptorBuilder(ModuleDescriptor md, Set<String> packages, int index) { |
1052 |
if (md.isAutomatic()) { |
|
1053 |
throw new InternalError("linking automatic module is not supported"); |
|
1054 |
} |
|
1055 |
this.md = md; |
|
1056 |
this.packages = packages; |
|
1057 |
this.index = index; |
|
1058 |
} |
|
1059 |
||
1060 |
void build() { |
|
1061 |
// new jdk.internal.module.Builder |
|
1062 |
newBuilder(); |
|
1063 |
||
1064 |
// requires |
|
1065 |
requires(md.requires()); |
|
1066 |
||
1067 |
// exports |
|
1068 |
exports(md.exports()); |
|
1069 |
||
1070 |
// opens |
|
1071 |
opens(md.opens()); |
|
1072 |
||
1073 |
// uses |
|
1074 |
uses(md.uses()); |
|
1075 |
||
1076 |
// provides |
|
1077 |
provides(md.provides()); |
|
1078 |
||
1079 |
// all packages |
|
1080 |
packages(packages); |
|
1081 |
||
1082 |
// version |
|
1083 |
md.version().ifPresent(this::version); |
|
1084 |
||
1085 |
// main class |
|
1086 |
md.mainClass().ifPresent(this::mainClass); |
|
1087 |
||
1088 |
putModuleDescriptor(); |
|
1089 |
} |
|
1090 |
||
1091 |
void newBuilder() { |
|
1092 |
mv.visitTypeInsn(NEW, MODULE_DESCRIPTOR_BUILDER); |
|
1093 |
mv.visitInsn(DUP); |
|
1094 |
mv.visitLdcInsn(md.name()); |
|
1095 |
mv.visitMethodInsn(INVOKESPECIAL, MODULE_DESCRIPTOR_BUILDER, |
|
1096 |
"<init>", "(Ljava/lang/String;)V", false); |
|
1097 |
mv.visitVarInsn(ASTORE, BUILDER_VAR); |
|
1098 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1099 |
||
1100 |
if (md.isOpen()) { |
|
1101 |
setModuleBit("open", true); |
|
1102 |
} |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43336
diff
changeset
|
1103 |
if (md.modifiers().contains(ModuleDescriptor.Modifier.SYNTHETIC)) { |
42703 | 1104 |
setModuleBit("synthetic", true); |
1105 |
} |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43336
diff
changeset
|
1106 |
if (md.modifiers().contains(ModuleDescriptor.Modifier.MANDATED)) { |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43336
diff
changeset
|
1107 |
setModuleBit("mandated", true); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
43336
diff
changeset
|
1108 |
} |
42703 | 1109 |
} |
1110 |
||
1111 |
/* |
|
1112 |
* Invoke Builder.<methodName>(boolean value) |
|
1113 |
*/ |
|
1114 |
void setModuleBit(String methodName, boolean value) { |
|
1115 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1116 |
if (value) { |
|
1117 |
mv.visitInsn(ICONST_1); |
|
1118 |
} else { |
|
1119 |
mv.visitInsn(ICONST_0); |
|
1120 |
} |
|
1121 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1122 |
methodName, BOOLEAN_SIG, false); |
|
1123 |
mv.visitInsn(POP); |
|
1124 |
} |
|
1125 |
||
1126 |
/* |
|
1127 |
* Put ModuleDescriptor into the modules array |
|
1128 |
*/ |
|
1129 |
void putModuleDescriptor() { |
|
1130 |
mv.visitVarInsn(ALOAD, MD_VAR); |
|
1131 |
pushInt(mv, index); |
|
1132 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1133 |
mv.visitLdcInsn(md.hashCode()); |
|
1134 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1135 |
"build", "(I)Ljava/lang/module/ModuleDescriptor;", |
|
1136 |
false); |
|
1137 |
mv.visitInsn(AASTORE); |
|
1138 |
} |
|
1139 |
||
1140 |
/* |
|
1141 |
* Call Builder::newRequires to create Requires instances and |
|
1142 |
* then pass it to the builder by calling: |
|
1143 |
* Builder.requires(Requires[]) |
|
1144 |
* |
|
1145 |
*/ |
|
1146 |
void requires(Set<Requires> requires) { |
|
1147 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1148 |
pushInt(mv, requires.size()); |
|
1149 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Requires"); |
|
1150 |
int arrayIndex = 0; |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1151 |
for (Requires require : sorted(requires)) { |
42703 | 1152 |
String compiledVersion = null; |
1153 |
if (require.compiledVersion().isPresent()) { |
|
1154 |
compiledVersion = require.compiledVersion().get().toString(); |
|
1155 |
} |
|
1156 |
||
1157 |
mv.visitInsn(DUP); // arrayref |
|
1158 |
pushInt(mv, arrayIndex++); |
|
1159 |
newRequires(require.modifiers(), require.name(), compiledVersion); |
|
1160 |
mv.visitInsn(AASTORE); |
|
1161 |
} |
|
1162 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1163 |
"requires", REQUIRES_ARRAY_SIG, false); |
|
1164 |
} |
|
1165 |
||
1166 |
/* |
|
1167 |
* Invoke Builder.newRequires(Set<Modifier> mods, String mn, String compiledVersion) |
|
1168 |
* |
|
1169 |
* Set<Modifier> mods = ... |
|
1170 |
* Builder.newRequires(mods, mn, compiledVersion); |
|
1171 |
*/ |
|
1172 |
void newRequires(Set<Requires.Modifier> mods, String name, String compiledVersion) { |
|
1173 |
int varIndex = dedupSetBuilder.indexOfRequiresModifiers(mods); |
|
1174 |
mv.visitVarInsn(ALOAD, varIndex); |
|
1175 |
mv.visitLdcInsn(name); |
|
1176 |
if (compiledVersion != null) { |
|
1177 |
mv.visitLdcInsn(compiledVersion); |
|
1178 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1179 |
"newRequires", REQUIRES_SET_STRING_STRING_SIG, false); |
|
1180 |
} else { |
|
1181 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1182 |
"newRequires", REQUIRES_SET_STRING_SIG, false); |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
/* |
|
1187 |
* Call Builder::newExports to create Exports instances and |
|
1188 |
* then pass it to the builder by calling: |
|
1189 |
* Builder.exports(Exports[]) |
|
1190 |
* |
|
1191 |
*/ |
|
1192 |
void exports(Set<Exports> exports) { |
|
1193 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1194 |
pushInt(mv, exports.size()); |
|
1195 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Exports"); |
|
1196 |
int arrayIndex = 0; |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1197 |
for (Exports export : sorted(exports)) { |
42703 | 1198 |
mv.visitInsn(DUP); // arrayref |
1199 |
pushInt(mv, arrayIndex++); |
|
1200 |
newExports(export.modifiers(), export.source(), export.targets()); |
|
1201 |
mv.visitInsn(AASTORE); |
|
1202 |
} |
|
1203 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1204 |
"exports", EXPORTS_ARRAY_SIG, false); |
|
1205 |
} |
|
1206 |
||
1207 |
/* |
|
1208 |
* Invoke |
|
1209 |
* Builder.newExports(Set<Exports.Modifier> ms, String pn, |
|
1210 |
* Set<String> targets) |
|
1211 |
* or |
|
1212 |
* Builder.newExports(Set<Exports.Modifier> ms, String pn) |
|
1213 |
* |
|
1214 |
* Set<String> targets = new HashSet<>(); |
|
1215 |
* targets.add(t); |
|
1216 |
* : |
|
1217 |
* : |
|
1218 |
* |
|
1219 |
* Set<Modifier> mods = ... |
|
1220 |
* Builder.newExports(mods, pn, targets); |
|
1221 |
*/ |
|
1222 |
void newExports(Set<Exports.Modifier> ms, String pn, Set<String> targets) { |
|
1223 |
int modifiersSetIndex = dedupSetBuilder.indexOfExportsModifiers(ms); |
|
1224 |
if (!targets.isEmpty()) { |
|
1225 |
int stringSetIndex = dedupSetBuilder.indexOfStringSet(targets); |
|
1226 |
mv.visitVarInsn(ALOAD, modifiersSetIndex); |
|
1227 |
mv.visitLdcInsn(pn); |
|
1228 |
mv.visitVarInsn(ALOAD, stringSetIndex); |
|
1229 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1230 |
"newExports", EXPORTS_MODIFIER_SET_STRING_SET_SIG, false); |
|
1231 |
} else { |
|
1232 |
mv.visitVarInsn(ALOAD, modifiersSetIndex); |
|
1233 |
mv.visitLdcInsn(pn); |
|
1234 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1235 |
"newExports", EXPORTS_MODIFIER_SET_STRING_SIG, false); |
|
1236 |
} |
|
1237 |
} |
|
1238 |
||
1239 |
||
1240 |
/** |
|
1241 |
* Call Builder::newOpens to create Opens instances and |
|
1242 |
* then pass it to the builder by calling: |
|
1243 |
* Builder.opens(Opens[]) |
|
1244 |
*/ |
|
1245 |
void opens(Set<Opens> opens) { |
|
1246 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1247 |
pushInt(mv, opens.size()); |
|
1248 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Opens"); |
|
1249 |
int arrayIndex = 0; |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1250 |
for (Opens open : sorted(opens)) { |
42703 | 1251 |
mv.visitInsn(DUP); // arrayref |
1252 |
pushInt(mv, arrayIndex++); |
|
1253 |
newOpens(open.modifiers(), open.source(), open.targets()); |
|
1254 |
mv.visitInsn(AASTORE); |
|
1255 |
} |
|
1256 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1257 |
"opens", OPENS_ARRAY_SIG, false); |
|
1258 |
} |
|
1259 |
||
1260 |
/* |
|
1261 |
* Invoke |
|
1262 |
* Builder.newOpens(Set<Opens.Modifier> ms, String pn, |
|
1263 |
* Set<String> targets) |
|
1264 |
* or |
|
1265 |
* Builder.newOpens(Set<Opens.Modifier> ms, String pn) |
|
1266 |
* |
|
1267 |
* Set<String> targets = new HashSet<>(); |
|
1268 |
* targets.add(t); |
|
1269 |
* : |
|
1270 |
* : |
|
1271 |
* |
|
1272 |
* Set<Modifier> mods = ... |
|
1273 |
* Builder.newOpens(mods, pn, targets); |
|
1274 |
*/ |
|
1275 |
void newOpens(Set<Opens.Modifier> ms, String pn, Set<String> targets) { |
|
1276 |
int modifiersSetIndex = dedupSetBuilder.indexOfOpensModifiers(ms); |
|
1277 |
if (!targets.isEmpty()) { |
|
1278 |
int stringSetIndex = dedupSetBuilder.indexOfStringSet(targets); |
|
1279 |
mv.visitVarInsn(ALOAD, modifiersSetIndex); |
|
1280 |
mv.visitLdcInsn(pn); |
|
1281 |
mv.visitVarInsn(ALOAD, stringSetIndex); |
|
1282 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1283 |
"newOpens", OPENS_MODIFIER_SET_STRING_SET_SIG, false); |
|
1284 |
} else { |
|
1285 |
mv.visitVarInsn(ALOAD, modifiersSetIndex); |
|
1286 |
mv.visitLdcInsn(pn); |
|
1287 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1288 |
"newOpens", OPENS_MODIFIER_SET_STRING_SIG, false); |
|
1289 |
} |
|
1290 |
} |
|
1291 |
||
1292 |
/* |
|
1293 |
* Invoke Builder.uses(Set<String> uses) |
|
1294 |
*/ |
|
1295 |
void uses(Set<String> uses) { |
|
1296 |
int varIndex = dedupSetBuilder.indexOfStringSet(uses); |
|
1297 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1298 |
mv.visitVarInsn(ALOAD, varIndex); |
|
1299 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1300 |
"uses", SET_SIG, false); |
|
1301 |
mv.visitInsn(POP); |
|
1302 |
} |
|
1303 |
||
1304 |
/* |
|
1305 |
* Call Builder::newProvides to create Provides instances and |
|
1306 |
* then pass it to the builder by calling: |
|
1307 |
* Builder.provides(Provides[] provides) |
|
1308 |
* |
|
1309 |
*/ |
|
1310 |
void provides(Collection<Provides> provides) { |
|
1311 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1312 |
pushInt(mv, provides.size()); |
|
1313 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Provides"); |
|
1314 |
int arrayIndex = 0; |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1315 |
for (Provides provide : sorted(provides)) { |
42703 | 1316 |
mv.visitInsn(DUP); // arrayref |
1317 |
pushInt(mv, arrayIndex++); |
|
1318 |
newProvides(provide.service(), provide.providers()); |
|
1319 |
mv.visitInsn(AASTORE); |
|
1320 |
} |
|
1321 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1322 |
"provides", PROVIDES_ARRAY_SIG, false); |
|
1323 |
} |
|
1324 |
||
1325 |
/* |
|
1326 |
* Invoke Builder.newProvides(String service, Set<String> providers) |
|
1327 |
* |
|
1328 |
* Set<String> providers = new HashSet<>(); |
|
1329 |
* providers.add(impl); |
|
1330 |
* : |
|
1331 |
* : |
|
1332 |
* Builder.newProvides(service, providers); |
|
1333 |
*/ |
|
1334 |
void newProvides(String service, List<String> providers) { |
|
1335 |
mv.visitLdcInsn(service); |
|
1336 |
pushInt(mv, providers.size()); |
|
1337 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); |
|
1338 |
int arrayIndex = 0; |
|
1339 |
for (String provider : providers) { |
|
1340 |
mv.visitInsn(DUP); // arrayref |
|
1341 |
pushInt(mv, arrayIndex++); |
|
1342 |
mv.visitLdcInsn(provider); |
|
1343 |
mv.visitInsn(AASTORE); |
|
1344 |
} |
|
1345 |
mv.visitMethodInsn(INVOKESTATIC, "java/util/List", |
|
1346 |
"of", "([Ljava/lang/Object;)Ljava/util/List;", true); |
|
1347 |
mv.visitMethodInsn(INVOKESTATIC, MODULE_DESCRIPTOR_BUILDER, |
|
1348 |
"newProvides", PROVIDES_STRING_LIST_SIG, false); |
|
1349 |
} |
|
1350 |
||
1351 |
/* |
|
1352 |
* Invoke Builder.packages(String pn) |
|
1353 |
*/ |
|
1354 |
void packages(Set<String> packages) { |
|
1355 |
int varIndex = dedupSetBuilder.newStringSet(packages); |
|
1356 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1357 |
mv.visitVarInsn(ALOAD, varIndex); |
|
1358 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1359 |
"packages", SET_SIG, false); |
|
1360 |
mv.visitInsn(POP); |
|
1361 |
} |
|
1362 |
||
1363 |
/* |
|
1364 |
* Invoke Builder.mainClass(String cn) |
|
1365 |
*/ |
|
1366 |
void mainClass(String cn) { |
|
1367 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1368 |
mv.visitLdcInsn(cn); |
|
1369 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1370 |
"mainClass", STRING_SIG, false); |
|
1371 |
mv.visitInsn(POP); |
|
1372 |
} |
|
1373 |
||
1374 |
/* |
|
1375 |
* Invoke Builder.version(Version v); |
|
1376 |
*/ |
|
1377 |
void version(Version v) { |
|
1378 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1379 |
mv.visitLdcInsn(v.toString()); |
|
1380 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
|
1381 |
"version", STRING_SIG, false); |
|
1382 |
mv.visitInsn(POP); |
|
1383 |
} |
|
43336
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1384 |
|
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1385 |
void invokeBuilderMethod(String methodName, String value) { |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1386 |
mv.visitVarInsn(ALOAD, BUILDER_VAR); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1387 |
mv.visitLdcInsn(value); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1388 |
mv.visitMethodInsn(INVOKEVIRTUAL, MODULE_DESCRIPTOR_BUILDER, |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1389 |
methodName, STRING_SIG, false); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1390 |
mv.visitInsn(POP); |
be9fca030f91
8173381: osName/osArch/osVersion is missing in ModuleDescriptor created by SystemModules
mchung
parents:
42770
diff
changeset
|
1391 |
} |
42703 | 1392 |
} |
1393 |
||
1394 |
class ModuleHashesBuilder { |
|
1395 |
private static final String MODULE_HASHES_BUILDER = |
|
1396 |
"jdk/internal/module/ModuleHashes$Builder"; |
|
1397 |
private static final String MODULE_HASHES_BUILDER_TYPE = |
|
1398 |
"L" + MODULE_HASHES_BUILDER + ";"; |
|
1399 |
static final String STRING_BYTE_ARRAY_SIG = |
|
1400 |
"(Ljava/lang/String;[B)" + MODULE_HASHES_BUILDER_TYPE; |
|
1401 |
||
1402 |
final ModuleHashes recordedHashes; |
|
1403 |
final MethodVisitor hmv; |
|
1404 |
final int index; |
|
1405 |
||
1406 |
ModuleHashesBuilder(ModuleHashes hashes, int index, MethodVisitor hmv) { |
|
1407 |
this.recordedHashes = hashes; |
|
1408 |
this.hmv = hmv; |
|
1409 |
this.index = index; |
|
1410 |
} |
|
1411 |
||
1412 |
/** |
|
1413 |
* Build ModuleHashes |
|
1414 |
*/ |
|
1415 |
void build() { |
|
1416 |
if (recordedHashes == null) |
|
1417 |
return; |
|
1418 |
||
1419 |
// new jdk.internal.module.ModuleHashes.Builder |
|
1420 |
newModuleHashesBuilder(); |
|
1421 |
||
1422 |
// Invoke ModuleHashes.Builder::hashForModule |
|
1423 |
recordedHashes |
|
1424 |
.names() |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1425 |
.stream() |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1426 |
.sorted() |
42703 | 1427 |
.forEach(mn -> hashForModule(mn, recordedHashes.hashFor(mn))); |
1428 |
||
1429 |
// Put ModuleHashes into the hashes array |
|
1430 |
pushModuleHashes(); |
|
1431 |
} |
|
1432 |
||
1433 |
||
1434 |
/* |
|
1435 |
* Create ModuleHashes.Builder instance |
|
1436 |
*/ |
|
1437 |
void newModuleHashesBuilder() { |
|
1438 |
hmv.visitTypeInsn(NEW, MODULE_HASHES_BUILDER); |
|
1439 |
hmv.visitInsn(DUP); |
|
1440 |
hmv.visitLdcInsn(recordedHashes.algorithm()); |
|
42752
844691c73832
8171373: Reduce copying during initialization of ModuleHashes
redestad
parents:
42703
diff
changeset
|
1441 |
pushInt(hmv, ((4 * recordedHashes.names().size()) / 3) + 1); |
42703 | 1442 |
hmv.visitMethodInsn(INVOKESPECIAL, MODULE_HASHES_BUILDER, |
42752
844691c73832
8171373: Reduce copying during initialization of ModuleHashes
redestad
parents:
42703
diff
changeset
|
1443 |
"<init>", "(Ljava/lang/String;I)V", false); |
42703 | 1444 |
hmv.visitVarInsn(ASTORE, BUILDER_VAR); |
1445 |
hmv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1446 |
} |
|
1447 |
||
1448 |
||
1449 |
/* |
|
1450 |
* Invoke ModuleHashes.Builder::build and put the returned |
|
1451 |
* ModuleHashes to the hashes array |
|
1452 |
*/ |
|
1453 |
void pushModuleHashes() { |
|
1454 |
hmv.visitVarInsn(ALOAD, MH_VAR); |
|
1455 |
pushInt(hmv, index); |
|
1456 |
hmv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1457 |
hmv.visitMethodInsn(INVOKEVIRTUAL, MODULE_HASHES_BUILDER, |
|
1458 |
"build", "()Ljdk/internal/module/ModuleHashes;", |
|
1459 |
false); |
|
1460 |
hmv.visitInsn(AASTORE); |
|
1461 |
} |
|
1462 |
||
1463 |
/* |
|
1464 |
* Invoke ModuleHashes.Builder.hashForModule(String name, byte[] hash); |
|
1465 |
*/ |
|
1466 |
void hashForModule(String name, byte[] hash) { |
|
1467 |
hmv.visitVarInsn(ALOAD, BUILDER_VAR); |
|
1468 |
hmv.visitLdcInsn(name); |
|
1469 |
||
1470 |
pushInt(hmv, hash.length); |
|
1471 |
hmv.visitIntInsn(NEWARRAY, T_BYTE); |
|
1472 |
for (int i = 0; i < hash.length; i++) { |
|
1473 |
hmv.visitInsn(DUP); // arrayref |
|
1474 |
pushInt(hmv, i); |
|
1475 |
hmv.visitIntInsn(BIPUSH, hash[i]); |
|
1476 |
hmv.visitInsn(BASTORE); |
|
1477 |
} |
|
1478 |
||
1479 |
hmv.visitMethodInsn(INVOKEVIRTUAL, MODULE_HASHES_BUILDER, |
|
1480 |
"hashForModule", STRING_BYTE_ARRAY_SIG, false); |
|
1481 |
hmv.visitInsn(POP); |
|
1482 |
} |
|
1483 |
} |
|
1484 |
||
1485 |
/* |
|
1486 |
* Wraps set creation, ensuring identical sets are properly deduplicated. |
|
1487 |
*/ |
|
1488 |
class DedupSetBuilder { |
|
1489 |
// map Set<String> to a specialized builder to allow them to be |
|
1490 |
// deduplicated as they are requested |
|
1491 |
final Map<Set<String>, SetBuilder<String>> stringSets = new HashMap<>(); |
|
1492 |
||
1493 |
// map Set<Requires.Modifier> to a specialized builder to allow them to be |
|
1494 |
// deduplicated as they are requested |
|
1495 |
final Map<Set<Requires.Modifier>, EnumSetBuilder<Requires.Modifier>> |
|
1496 |
requiresModifiersSets = new HashMap<>(); |
|
1497 |
||
1498 |
// map Set<Exports.Modifier> to a specialized builder to allow them to be |
|
1499 |
// deduplicated as they are requested |
|
1500 |
final Map<Set<Exports.Modifier>, EnumSetBuilder<Exports.Modifier>> |
|
1501 |
exportsModifiersSets = new HashMap<>(); |
|
1502 |
||
1503 |
// map Set<Opens.Modifier> to a specialized builder to allow them to be |
|
1504 |
// deduplicated as they are requested |
|
1505 |
final Map<Set<Opens.Modifier>, EnumSetBuilder<Opens.Modifier>> |
|
1506 |
opensModifiersSets = new HashMap<>(); |
|
1507 |
||
1508 |
private final int stringSetVar; |
|
1509 |
private final int enumSetVar; |
|
1510 |
private final IntSupplier localVarSupplier; |
|
1511 |
||
1512 |
DedupSetBuilder(IntSupplier localVarSupplier) { |
|
1513 |
this.stringSetVar = localVarSupplier.getAsInt(); |
|
1514 |
this.enumSetVar = localVarSupplier.getAsInt(); |
|
1515 |
this.localVarSupplier = localVarSupplier; |
|
1516 |
} |
|
1517 |
||
1518 |
/* |
|
1519 |
* Add the given set of strings to this builder. |
|
1520 |
*/ |
|
1521 |
void stringSet(Set<String> strings) { |
|
1522 |
stringSets.computeIfAbsent(strings, |
|
1523 |
s -> new SetBuilder<>(s, stringSetVar, localVarSupplier) |
|
1524 |
).increment(); |
|
1525 |
} |
|
1526 |
||
1527 |
/* |
|
1528 |
* Add the given set of Exports.Modifiers |
|
1529 |
*/ |
|
1530 |
void exportsModifiers(Set<Exports.Modifier> mods) { |
|
1531 |
exportsModifiersSets.computeIfAbsent(mods, s -> |
|
1532 |
new EnumSetBuilder<>(s, EXPORTS_MODIFIER_CLASSNAME, |
|
1533 |
enumSetVar, localVarSupplier) |
|
1534 |
).increment(); |
|
1535 |
} |
|
1536 |
||
1537 |
/* |
|
1538 |
* Add the given set of Opens.Modifiers |
|
1539 |
*/ |
|
1540 |
void opensModifiers(Set<Opens.Modifier> mods) { |
|
1541 |
opensModifiersSets.computeIfAbsent(mods, s -> |
|
1542 |
new EnumSetBuilder<>(s, OPENS_MODIFIER_CLASSNAME, |
|
1543 |
enumSetVar, localVarSupplier) |
|
1544 |
).increment(); |
|
1545 |
} |
|
1546 |
||
1547 |
/* |
|
1548 |
* Add the given set of Requires.Modifiers |
|
1549 |
*/ |
|
1550 |
void requiresModifiers(Set<Requires.Modifier> mods) { |
|
1551 |
requiresModifiersSets.computeIfAbsent(mods, s -> |
|
1552 |
new EnumSetBuilder<>(s, REQUIRES_MODIFIER_CLASSNAME, |
|
1553 |
enumSetVar, localVarSupplier) |
|
1554 |
).increment(); |
|
1555 |
} |
|
1556 |
||
1557 |
/* |
|
1558 |
* Retrieve the index to the given set of Strings. Emit code to |
|
1559 |
* generate it when SetBuilder::build is called. |
|
1560 |
*/ |
|
1561 |
int indexOfStringSet(Set<String> names) { |
|
1562 |
return stringSets.get(names).build(); |
|
1563 |
} |
|
1564 |
||
1565 |
/* |
|
1566 |
* Retrieve the index to the given set of Exports.Modifier. |
|
1567 |
* Emit code to generate it when EnumSetBuilder::build is called. |
|
1568 |
*/ |
|
1569 |
int indexOfExportsModifiers(Set<Exports.Modifier> mods) { |
|
1570 |
return exportsModifiersSets.get(mods).build(); |
|
1571 |
} |
|
1572 |
||
1573 |
/** |
|
1574 |
* Retrieve the index to the given set of Opens.Modifier. |
|
1575 |
* Emit code to generate it when EnumSetBuilder::build is called. |
|
1576 |
*/ |
|
1577 |
int indexOfOpensModifiers(Set<Opens.Modifier> mods) { |
|
1578 |
return opensModifiersSets.get(mods).build(); |
|
1579 |
} |
|
1580 |
||
1581 |
||
1582 |
/* |
|
1583 |
* Retrieve the index to the given set of Requires.Modifier. |
|
1584 |
* Emit code to generate it when EnumSetBuilder::build is called. |
|
1585 |
*/ |
|
1586 |
int indexOfRequiresModifiers(Set<Requires.Modifier> mods) { |
|
1587 |
return requiresModifiersSets.get(mods).build(); |
|
1588 |
} |
|
1589 |
||
1590 |
/* |
|
1591 |
* Build a new string set without any attempt to deduplicate it. |
|
1592 |
*/ |
|
1593 |
int newStringSet(Set<String> names) { |
|
1594 |
int index = new SetBuilder<>(names, stringSetVar, localVarSupplier).build(); |
|
1595 |
assert index == stringSetVar; |
|
1596 |
return index; |
|
1597 |
} |
|
1598 |
} |
|
1599 |
||
1600 |
/* |
|
1601 |
* SetBuilder generates bytecode to create one single instance of Set |
|
1602 |
* for a given set of elements and assign to a local variable slot. |
|
1603 |
* When there is only one single reference to a Set<T>, |
|
1604 |
* it will reuse defaultVarIndex. For a Set with multiple references, |
|
1605 |
* it will use a new local variable retrieved from the nextLocalVar |
|
1606 |
*/ |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1607 |
class SetBuilder<T extends Comparable<T>> { |
42703 | 1608 |
private final Set<T> elements; |
1609 |
private final int defaultVarIndex; |
|
1610 |
private final IntSupplier nextLocalVar; |
|
1611 |
private int refCount; |
|
1612 |
private int localVarIndex; |
|
1613 |
||
1614 |
SetBuilder(Set<T> elements, |
|
1615 |
int defaultVarIndex, |
|
1616 |
IntSupplier nextLocalVar) { |
|
1617 |
this.elements = elements; |
|
1618 |
this.defaultVarIndex = defaultVarIndex; |
|
1619 |
this.nextLocalVar = nextLocalVar; |
|
1620 |
} |
|
1621 |
||
1622 |
/* |
|
1623 |
* Increments the number of references to this particular set. |
|
1624 |
*/ |
|
1625 |
final void increment() { |
|
1626 |
refCount++; |
|
1627 |
} |
|
1628 |
||
1629 |
/** |
|
1630 |
* Generate the appropriate instructions to load an object reference |
|
1631 |
* to the element onto the stack. |
|
1632 |
*/ |
|
1633 |
void visitElement(T element, MethodVisitor mv) { |
|
1634 |
mv.visitLdcInsn(element); |
|
1635 |
} |
|
1636 |
||
1637 |
/* |
|
1638 |
* Build bytecode for the Set represented by this builder, |
|
1639 |
* or get the local variable index of a previously generated set |
|
1640 |
* (in the local scope). |
|
1641 |
* |
|
1642 |
* @return local variable index of the generated set. |
|
1643 |
*/ |
|
1644 |
final int build() { |
|
1645 |
int index = localVarIndex; |
|
1646 |
if (localVarIndex == 0) { |
|
1647 |
// if non-empty and more than one set reference this builder, |
|
1648 |
// emit to a unique local |
|
1649 |
index = refCount <= 1 ? defaultVarIndex |
|
1650 |
: nextLocalVar.getAsInt(); |
|
1651 |
if (index < MAX_LOCAL_VARS) { |
|
1652 |
localVarIndex = index; |
|
1653 |
} else { |
|
1654 |
// overflow: disable optimization by using localVarIndex = 0 |
|
1655 |
index = defaultVarIndex; |
|
1656 |
} |
|
1657 |
||
1658 |
generateSetOf(index); |
|
1659 |
} |
|
1660 |
return index; |
|
1661 |
} |
|
1662 |
||
1663 |
private void generateSetOf(int index) { |
|
1664 |
if (elements.size() <= 10) { |
|
1665 |
// call Set.of(e1, e2, ...) |
|
1666 |
StringBuilder sb = new StringBuilder("("); |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1667 |
for (T t : sorted(elements)) { |
42703 | 1668 |
sb.append("Ljava/lang/Object;"); |
1669 |
visitElement(t, mv); |
|
1670 |
} |
|
1671 |
sb.append(")Ljava/util/Set;"); |
|
1672 |
mv.visitMethodInsn(INVOKESTATIC, "java/util/Set", |
|
1673 |
"of", sb.toString(), true); |
|
1674 |
} else { |
|
1675 |
// call Set.of(E... elements) |
|
1676 |
pushInt(mv, elements.size()); |
|
1677 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); |
|
1678 |
int arrayIndex = 0; |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1679 |
for (T t : sorted(elements)) { |
42703 | 1680 |
mv.visitInsn(DUP); // arrayref |
1681 |
pushInt(mv, arrayIndex); |
|
1682 |
visitElement(t, mv); // value |
|
1683 |
mv.visitInsn(AASTORE); |
|
1684 |
arrayIndex++; |
|
1685 |
} |
|
1686 |
mv.visitMethodInsn(INVOKESTATIC, "java/util/Set", |
|
1687 |
"of", "([Ljava/lang/Object;)Ljava/util/Set;", true); |
|
1688 |
} |
|
1689 |
mv.visitVarInsn(ASTORE, index); |
|
1690 |
} |
|
1691 |
} |
|
1692 |
||
1693 |
/* |
|
1694 |
* Generates bytecode to create one single instance of EnumSet |
|
1695 |
* for a given set of modifiers and assign to a local variable slot. |
|
1696 |
*/ |
|
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1697 |
class EnumSetBuilder<T extends Comparable<T>> extends SetBuilder<T> { |
42703 | 1698 |
|
1699 |
private final String className; |
|
1700 |
||
1701 |
EnumSetBuilder(Set<T> modifiers, String className, |
|
1702 |
int defaultVarIndex, |
|
1703 |
IntSupplier nextLocalVar) { |
|
1704 |
super(modifiers, defaultVarIndex, nextLocalVar); |
|
1705 |
this.className = className; |
|
1706 |
} |
|
1707 |
||
1708 |
/** |
|
1709 |
* Loads an Enum field. |
|
1710 |
*/ |
|
1711 |
void visitElement(T t, MethodVisitor mv) { |
|
1712 |
mv.visitFieldInsn(GETSTATIC, className, t.toString(), |
|
1713 |
"L" + className + ";"); |
|
1714 |
} |
|
1715 |
} |
|
1716 |
} |
|
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1717 |
|
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1718 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1719 |
* Generate SystemModulesMap and add it as a resource. |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1720 |
* |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1721 |
* @return the name of the class resource added to the pool |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1722 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1723 |
private String genSystemModulesMapClass(String allSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1724 |
String defaultSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1725 |
Map<String, String> map, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1726 |
ResourcePoolBuilder out) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1727 |
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1728 |
+ ClassWriter.COMPUTE_FRAMES); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1729 |
cw.visit(Opcodes.V1_8, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1730 |
ACC_FINAL+ACC_SUPER, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1731 |
SYSTEM_MODULES_MAP_CLASS, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1732 |
null, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1733 |
"java/lang/Object", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1734 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1735 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1736 |
// <init> |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1737 |
MethodVisitor mv = cw.visitMethod(0, "<init>", "()V", null, null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1738 |
mv.visitVarInsn(ALOAD, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1739 |
mv.visitMethodInsn(INVOKESPECIAL, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1740 |
"java/lang/Object", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1741 |
"<init>", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1742 |
"()V", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1743 |
false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1744 |
mv.visitInsn(RETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1745 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1746 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1747 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1748 |
// allSystemModules() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1749 |
mv = cw.visitMethod(ACC_STATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1750 |
"allSystemModules", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1751 |
"()Ljdk/internal/module/SystemModules;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1752 |
"()Ljdk/internal/module/SystemModules;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1753 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1754 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1755 |
mv.visitTypeInsn(NEW, allSystemModulesClassName); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1756 |
mv.visitInsn(DUP); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1757 |
mv.visitMethodInsn(INVOKESPECIAL, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1758 |
allSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1759 |
"<init>", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1760 |
"()V", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1761 |
false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1762 |
mv.visitInsn(ARETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1763 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1764 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1765 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1766 |
// defaultSystemModules() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1767 |
mv = cw.visitMethod(ACC_STATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1768 |
"defaultSystemModules", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1769 |
"()Ljdk/internal/module/SystemModules;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1770 |
"()Ljdk/internal/module/SystemModules;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1771 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1772 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1773 |
mv.visitTypeInsn(NEW, defaultSystemModulesClassName); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1774 |
mv.visitInsn(DUP); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1775 |
mv.visitMethodInsn(INVOKESPECIAL, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1776 |
defaultSystemModulesClassName, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1777 |
"<init>", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1778 |
"()V", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1779 |
false); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1780 |
mv.visitInsn(ARETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1781 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1782 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1783 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1784 |
// moduleNames() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1785 |
mv = cw.visitMethod(ACC_STATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1786 |
"moduleNames", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1787 |
"()[Ljava/lang/String;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1788 |
"()[Ljava/lang/String;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1789 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1790 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1791 |
pushInt(mv, map.size()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1792 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1793 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1794 |
int index = 0; |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1795 |
for (String moduleName : sorted(map.keySet())) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1796 |
mv.visitInsn(DUP); // arrayref |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1797 |
pushInt(mv, index); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1798 |
mv.visitLdcInsn(moduleName); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1799 |
mv.visitInsn(AASTORE); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1800 |
index++; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1801 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1802 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1803 |
mv.visitInsn(ARETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1804 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1805 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1806 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1807 |
// classNames() |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1808 |
mv = cw.visitMethod(ACC_STATIC, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1809 |
"classNames", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1810 |
"()[Ljava/lang/String;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1811 |
"()[Ljava/lang/String;", |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1812 |
null); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1813 |
mv.visitCode(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1814 |
pushInt(mv, map.size()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1815 |
mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1816 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1817 |
index = 0; |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1818 |
for (String className : sorted(map.values())) { |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1819 |
mv.visitInsn(DUP); // arrayref |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1820 |
pushInt(mv, index); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1821 |
mv.visitLdcInsn(className.replace('/', '.')); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1822 |
mv.visitInsn(AASTORE); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1823 |
index++; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1824 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1825 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1826 |
mv.visitInsn(ARETURN); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1827 |
mv.visitMaxs(0, 0); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1828 |
mv.visitEnd(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1829 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1830 |
// write the class file to the pool as a resource |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1831 |
String rn = "/java.base/" + SYSTEM_MODULES_MAP_CLASS + ".class"; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1832 |
ResourcePoolEntry e = ResourcePoolEntry.create(rn, cw.toByteArray()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1833 |
out.add(e); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1834 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1835 |
return rn; |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1836 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1837 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1838 |
/** |
52814
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1839 |
* Returns a sorted copy of a collection. |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1840 |
* |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1841 |
* This is useful to ensure a deterministic iteration order. |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1842 |
* |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1843 |
* @return a sorted copy of the given collection. |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1844 |
*/ |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1845 |
private static <T extends Comparable<T>> List<T> sorted(Collection<T> c) { |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1846 |
var l = new ArrayList<T>(c); |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1847 |
Collections.sort(l); |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1848 |
return l; |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1849 |
} |
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1850 |
|
abccada595dd
8214230: Classes generated by SystemModulesPlugin.java are not reproducable
ehelin
parents:
52515
diff
changeset
|
1851 |
/** |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1852 |
* Pushes an int constant |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1853 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1854 |
private static void pushInt(MethodVisitor mv, int value) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1855 |
if (value <= 5) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1856 |
mv.visitInsn(ICONST_0 + value); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1857 |
} else if (value < Byte.MAX_VALUE) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1858 |
mv.visitIntInsn(BIPUSH, value); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1859 |
} else if (value < Short.MAX_VALUE) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1860 |
mv.visitIntInsn(SIPUSH, value); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1861 |
} else { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1862 |
throw new IllegalArgumentException("exceed limit: " + value); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1863 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1864 |
} |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1865 |
|
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1866 |
/** |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1867 |
* Returns a module finder that finds all modules in the given list |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1868 |
*/ |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1869 |
private static ModuleFinder finderOf(Collection<ModuleInfo> moduleInfos) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1870 |
Supplier<ModuleReader> readerSupplier = () -> null; |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1871 |
Map<String, ModuleReference> namesToReference = new HashMap<>(); |
46096
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1872 |
for (ModuleInfo mi : moduleInfos) { |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1873 |
String name = mi.moduleName(); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1874 |
ModuleReference mref |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1875 |
= new ModuleReferenceImpl(mi.descriptor(), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1876 |
URI.create("jrt:/" + name), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1877 |
readerSupplier, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1878 |
null, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1879 |
mi.target(), |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1880 |
null, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1881 |
null, |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1882 |
mi.moduleResolution()); |
62c77b334012
8185853: Generate readability graph at link time and other startup improvements
alanb
parents:
45652
diff
changeset
|
1883 |
namesToReference.put(name, mref); |
45652
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1884 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1885 |
|
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1886 |
return new ModuleFinder() { |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1887 |
@Override |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1888 |
public Optional<ModuleReference> find(String name) { |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1889 |
Objects.requireNonNull(name); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1890 |
return Optional.ofNullable(namesToReference.get(name)); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1891 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1892 |
@Override |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1893 |
public Set<ModuleReference> findAll() { |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1894 |
return new HashSet<>(namesToReference.values()); |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1895 |
} |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1896 |
}; |
33342314ce89
8181087: Module system implementation refresh (6/2017)
alanb
parents:
45004
diff
changeset
|
1897 |
} |
42703 | 1898 |
} |