author | rriggs |
Sun, 29 Oct 2017 18:20:53 -0400 | |
changeset 47471 | 304ef03403b1 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
36511 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.internal.module; |
|
27 |
||
28 |
import java.lang.module.ModuleDescriptor; |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
29 |
import java.lang.module.ModuleDescriptor.Builder; |
36511 | 30 |
import java.lang.module.ModuleDescriptor.Requires; |
31 |
import java.lang.module.ModuleDescriptor.Exports; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
32 |
import java.lang.module.ModuleDescriptor.Opens; |
36511 | 33 |
import java.lang.module.ModuleDescriptor.Provides; |
34 |
import java.lang.module.ModuleDescriptor.Version; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
35 |
import java.util.ArrayList; |
36511 | 36 |
import java.util.Collections; |
37 |
import java.util.HashMap; |
|
38 |
import java.util.HashSet; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
39 |
import java.util.List; |
36511 | 40 |
import java.util.Map; |
41 |
import java.util.Set; |
|
42 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
43 |
import jdk.internal.misc.JavaLangModuleAccess; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
44 |
import jdk.internal.misc.SharedSecrets; |
36511 | 45 |
import jdk.internal.org.objectweb.asm.Attribute; |
46 |
import jdk.internal.org.objectweb.asm.ByteVector; |
|
47 |
import jdk.internal.org.objectweb.asm.ClassReader; |
|
48 |
import jdk.internal.org.objectweb.asm.ClassWriter; |
|
49 |
import jdk.internal.org.objectweb.asm.Label; |
|
50 |
import static jdk.internal.module.ClassFileConstants.*; |
|
51 |
||
52 |
||
53 |
/** |
|
54 |
* Provides ASM implementations of {@code Attribute} to read and write the |
|
55 |
* class file attributes in a module-info class file. |
|
56 |
*/ |
|
57 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
58 |
public final class ClassFileAttributes { |
36511 | 59 |
|
60 |
private ClassFileAttributes() { } |
|
61 |
||
62 |
/** |
|
63 |
* Module_attribute { |
|
64 |
* // See lang-vm.html for details. |
|
65 |
* } |
|
66 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
67 |
public static class ModuleAttribute extends Attribute { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
68 |
private static final JavaLangModuleAccess JLMA |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
69 |
= SharedSecrets.getJavaLangModuleAccess(); |
36511 | 70 |
|
71 |
private ModuleDescriptor descriptor; |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
72 |
private Version replacementVersion; |
36511 | 73 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
74 |
public ModuleAttribute(ModuleDescriptor descriptor) { |
36511 | 75 |
super(MODULE); |
76 |
this.descriptor = descriptor; |
|
77 |
} |
|
78 |
||
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
79 |
public ModuleAttribute(Version v) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
80 |
super(MODULE); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
81 |
this.replacementVersion = v; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
82 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
83 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
84 |
public ModuleAttribute() { |
36511 | 85 |
super(MODULE); |
86 |
} |
|
87 |
||
88 |
@Override |
|
89 |
protected Attribute read(ClassReader cr, |
|
90 |
int off, |
|
91 |
int len, |
|
92 |
char[] buf, |
|
93 |
int codeOff, |
|
94 |
Label[] labels) |
|
95 |
{ |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
96 |
// module_name (CONSTANT_Module_info) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
97 |
String mn = cr.readModule(off, buf); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
98 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
99 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
100 |
// module_flags |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
101 |
int module_flags = cr.readUnsignedShort(off); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
102 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
103 |
|
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
104 |
Set<ModuleDescriptor.Modifier> modifiers = new HashSet<>(); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
105 |
if ((module_flags & ACC_OPEN) != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
106 |
modifiers.add(ModuleDescriptor.Modifier.OPEN); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
107 |
if ((module_flags & ACC_SYNTHETIC) != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
108 |
modifiers.add(ModuleDescriptor.Modifier.SYNTHETIC); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
109 |
if ((module_flags & ACC_MANDATED) != 0) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
110 |
modifiers.add(ModuleDescriptor.Modifier.MANDATED); |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
111 |
|
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
112 |
Builder builder = JLMA.newModuleBuilder(mn, false, modifiers); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
113 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
114 |
// module_version |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
115 |
String module_version = cr.readUTF8(off, buf); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
116 |
off += 2; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
117 |
if (replacementVersion != null) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
118 |
builder.version(replacementVersion); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
119 |
} else if (module_version != null) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
120 |
builder.version(module_version); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
121 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
122 |
|
36511 | 123 |
// requires_count and requires[requires_count] |
124 |
int requires_count = cr.readUnsignedShort(off); |
|
125 |
off += 2; |
|
126 |
for (int i=0; i<requires_count; i++) { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
127 |
// CONSTANT_Module_info |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
128 |
String dn = cr.readModule(off, buf); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
129 |
off += 2; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
130 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
131 |
// requires_flags |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
132 |
int requires_flags = cr.readUnsignedShort(off); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
133 |
off += 2; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
134 |
Set<Requires.Modifier> mods; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
135 |
if (requires_flags == 0) { |
36511 | 136 |
mods = Collections.emptySet(); |
137 |
} else { |
|
138 |
mods = new HashSet<>(); |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
139 |
if ((requires_flags & ACC_TRANSITIVE) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
140 |
mods.add(Requires.Modifier.TRANSITIVE); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
141 |
if ((requires_flags & ACC_STATIC_PHASE) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
142 |
mods.add(Requires.Modifier.STATIC); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
143 |
if ((requires_flags & ACC_SYNTHETIC) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
144 |
mods.add(Requires.Modifier.SYNTHETIC); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
145 |
if ((requires_flags & ACC_MANDATED) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
146 |
mods.add(Requires.Modifier.MANDATED); |
36511 | 147 |
} |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
148 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
149 |
// requires_version |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
150 |
String requires_version = cr.readUTF8(off, buf); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
151 |
off += 2; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
152 |
if (requires_version == null) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
153 |
builder.requires(mods, dn); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
154 |
} else { |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
155 |
JLMA.requires(builder, mods, dn, requires_version); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
156 |
} |
36511 | 157 |
} |
158 |
||
159 |
// exports_count and exports[exports_count] |
|
160 |
int exports_count = cr.readUnsignedShort(off); |
|
161 |
off += 2; |
|
162 |
if (exports_count > 0) { |
|
163 |
for (int i=0; i<exports_count; i++) { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
164 |
// CONSTANT_Package_info |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
165 |
String pkg = cr.readPackage(off, buf).replace('/', '.'); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
166 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
167 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
168 |
int exports_flags = cr.readUnsignedShort(off); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
169 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
170 |
Set<Exports.Modifier> mods; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
171 |
if (exports_flags == 0) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
172 |
mods = Collections.emptySet(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
173 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
174 |
mods = new HashSet<>(); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
175 |
if ((exports_flags & ACC_SYNTHETIC) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
176 |
mods.add(Exports.Modifier.SYNTHETIC); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
177 |
if ((exports_flags & ACC_MANDATED) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
178 |
mods.add(Exports.Modifier.MANDATED); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
179 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
180 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
181 |
int exports_to_count = cr.readUnsignedShort(off); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
182 |
off += 2; |
36511 | 183 |
if (exports_to_count > 0) { |
184 |
Set<String> targets = new HashSet<>(); |
|
185 |
for (int j=0; j<exports_to_count; j++) { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
186 |
String t = cr.readModule(off, buf); |
36511 | 187 |
off += 2; |
188 |
targets.add(t); |
|
189 |
} |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
190 |
builder.exports(mods, pkg, targets); |
36511 | 191 |
} else { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
192 |
builder.exports(mods, pkg); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
193 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
194 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
195 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
196 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
197 |
// opens_count and opens[opens_count] |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
198 |
int open_count = cr.readUnsignedShort(off); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
199 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
200 |
if (open_count > 0) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
201 |
for (int i=0; i<open_count; i++) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
202 |
// CONSTANT_Package_info |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
203 |
String pkg = cr.readPackage(off, buf).replace('/', '.'); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
204 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
205 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
206 |
int opens_flags = cr.readUnsignedShort(off); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
207 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
208 |
Set<Opens.Modifier> mods; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
209 |
if (opens_flags == 0) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
210 |
mods = Collections.emptySet(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
211 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
212 |
mods = new HashSet<>(); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
213 |
if ((opens_flags & ACC_SYNTHETIC) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
214 |
mods.add(Opens.Modifier.SYNTHETIC); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
215 |
if ((opens_flags & ACC_MANDATED) != 0) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
216 |
mods.add(Opens.Modifier.MANDATED); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
217 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
218 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
219 |
int opens_to_count = cr.readUnsignedShort(off); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
220 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
221 |
if (opens_to_count > 0) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
222 |
Set<String> targets = new HashSet<>(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
223 |
for (int j=0; j<opens_to_count; j++) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
224 |
String t = cr.readModule(off, buf); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
225 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
226 |
targets.add(t); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
227 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
228 |
builder.opens(mods, pkg, targets); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
229 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
230 |
builder.opens(mods, pkg); |
36511 | 231 |
} |
232 |
} |
|
233 |
} |
|
234 |
||
235 |
// uses_count and uses_index[uses_count] |
|
236 |
int uses_count = cr.readUnsignedShort(off); |
|
237 |
off += 2; |
|
238 |
if (uses_count > 0) { |
|
239 |
for (int i=0; i<uses_count; i++) { |
|
240 |
String sn = cr.readClass(off, buf).replace('/', '.'); |
|
241 |
builder.uses(sn); |
|
242 |
off += 2; |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
// provides_count and provides[provides_count] |
|
247 |
int provides_count = cr.readUnsignedShort(off); |
|
248 |
off += 2; |
|
249 |
if (provides_count > 0) { |
|
250 |
for (int i=0; i<provides_count; i++) { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
251 |
String service = cr.readClass(off, buf).replace('/', '.'); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
252 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
253 |
int with_count = cr.readUnsignedShort(off); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
254 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
255 |
List<String> providers = new ArrayList<>(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
256 |
for (int j=0; j<with_count; j++) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
257 |
String cn = cr.readClass(off, buf).replace('/', '.'); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
258 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
259 |
providers.add(cn); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
260 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
261 |
builder.provides(service, providers); |
36511 | 262 |
} |
263 |
} |
|
264 |
||
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
265 |
return new ModuleAttribute(builder.build()); |
36511 | 266 |
} |
267 |
||
268 |
@Override |
|
269 |
protected ByteVector write(ClassWriter cw, |
|
270 |
byte[] code, |
|
271 |
int len, |
|
272 |
int maxStack, |
|
273 |
int maxLocals) |
|
274 |
{ |
|
275 |
assert descriptor != null; |
|
276 |
ByteVector attr = new ByteVector(); |
|
277 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
278 |
// module_name |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
279 |
String mn = descriptor.name(); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
280 |
int module_name_index = cw.newModule(mn); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
281 |
attr.putShort(module_name_index); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
282 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
283 |
// module_flags |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
284 |
Set<ModuleDescriptor.Modifier> modifiers = descriptor.modifiers(); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
285 |
int module_flags = 0; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
286 |
if (modifiers.contains(ModuleDescriptor.Modifier.OPEN)) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
287 |
module_flags |= ACC_OPEN; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
288 |
if (modifiers.contains(ModuleDescriptor.Modifier.SYNTHETIC)) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
289 |
module_flags |= ACC_SYNTHETIC; |
43712
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
290 |
if (modifiers.contains(ModuleDescriptor.Modifier.MANDATED)) |
5dfd0950317c
8173393: Module system implementation refresh (2/2017)
alanb
parents:
42703
diff
changeset
|
291 |
module_flags |= ACC_MANDATED; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
292 |
attr.putShort(module_flags); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
293 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
294 |
// module_version |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
295 |
String vs = descriptor.rawVersion().orElse(null); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
296 |
if (vs == null) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
297 |
attr.putShort(0); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
298 |
} else { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
299 |
int module_version_index = cw.newUTF8(vs); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
300 |
attr.putShort(module_version_index); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
301 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
302 |
|
36511 | 303 |
// requires_count |
304 |
attr.putShort(descriptor.requires().size()); |
|
305 |
||
306 |
// requires[requires_count] |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
307 |
for (Requires r : descriptor.requires()) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
308 |
int requires_index = cw.newModule(r.name()); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
309 |
attr.putShort(requires_index); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
310 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
311 |
int requires_flags = 0; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
312 |
if (r.modifiers().contains(Requires.Modifier.TRANSITIVE)) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
313 |
requires_flags |= ACC_TRANSITIVE; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
314 |
if (r.modifiers().contains(Requires.Modifier.STATIC)) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
315 |
requires_flags |= ACC_STATIC_PHASE; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
316 |
if (r.modifiers().contains(Requires.Modifier.SYNTHETIC)) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
317 |
requires_flags |= ACC_SYNTHETIC; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
318 |
if (r.modifiers().contains(Requires.Modifier.MANDATED)) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
319 |
requires_flags |= ACC_MANDATED; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
320 |
attr.putShort(requires_flags); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
321 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
322 |
int requires_version_index; |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
323 |
vs = r.rawCompiledVersion().orElse(null); |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
324 |
if (vs == null) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
325 |
requires_version_index = 0; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
326 |
} else { |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
327 |
requires_version_index = cw.newUTF8(vs); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
328 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
329 |
attr.putShort(requires_version_index); |
36511 | 330 |
} |
331 |
||
332 |
// exports_count and exports[exports_count]; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
333 |
attr.putShort(descriptor.exports().size()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
334 |
for (Exports e : descriptor.exports()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
335 |
String pkg = e.source().replace('.', '/'); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
336 |
attr.putShort(cw.newPackage(pkg)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
337 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
338 |
int exports_flags = 0; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
339 |
if (e.modifiers().contains(Exports.Modifier.SYNTHETIC)) |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
340 |
exports_flags |= ACC_SYNTHETIC; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
341 |
if (e.modifiers().contains(Exports.Modifier.MANDATED)) |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
342 |
exports_flags |= ACC_MANDATED; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
343 |
attr.putShort(exports_flags); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
344 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
345 |
if (e.isQualified()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
346 |
Set<String> ts = e.targets(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
347 |
attr.putShort(ts.size()); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
348 |
ts.forEach(target -> attr.putShort(cw.newModule(target))); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
349 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
350 |
attr.putShort(0); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
351 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
352 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
353 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
354 |
// opens_counts and opens[opens_counts] |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
355 |
attr.putShort(descriptor.opens().size()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
356 |
for (Opens obj : descriptor.opens()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
357 |
String pkg = obj.source().replace('.', '/'); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
358 |
attr.putShort(cw.newPackage(pkg)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
359 |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
360 |
int opens_flags = 0; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
361 |
if (obj.modifiers().contains(Opens.Modifier.SYNTHETIC)) |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
362 |
opens_flags |= ACC_SYNTHETIC; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
363 |
if (obj.modifiers().contains(Opens.Modifier.MANDATED)) |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
364 |
opens_flags |= ACC_MANDATED; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
365 |
attr.putShort(opens_flags); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
366 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
367 |
if (obj.isQualified()) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
368 |
Set<String> ts = obj.targets(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
369 |
attr.putShort(ts.size()); |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
370 |
ts.forEach(target -> attr.putShort(cw.newModule(target))); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
371 |
} else { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
372 |
attr.putShort(0); |
36511 | 373 |
} |
374 |
} |
|
375 |
||
376 |
// uses_count and uses_index[uses_count] |
|
377 |
if (descriptor.uses().isEmpty()) { |
|
378 |
attr.putShort(0); |
|
379 |
} else { |
|
380 |
attr.putShort(descriptor.uses().size()); |
|
381 |
for (String s : descriptor.uses()) { |
|
382 |
String service = s.replace('.', '/'); |
|
383 |
int index = cw.newClass(service); |
|
384 |
attr.putShort(index); |
|
385 |
} |
|
386 |
} |
|
387 |
||
388 |
// provides_count and provides[provides_count] |
|
389 |
if (descriptor.provides().isEmpty()) { |
|
390 |
attr.putShort(0); |
|
391 |
} else { |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
392 |
attr.putShort(descriptor.provides().size()); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
393 |
for (Provides p : descriptor.provides()) { |
36511 | 394 |
String service = p.service().replace('.', '/'); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
395 |
attr.putShort(cw.newClass(service)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
396 |
int with_count = p.providers().size(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
397 |
attr.putShort(with_count); |
36511 | 398 |
for (String provider : p.providers()) { |
399 |
attr.putShort(cw.newClass(provider.replace('.', '/'))); |
|
400 |
} |
|
401 |
} |
|
402 |
} |
|
403 |
||
404 |
return attr; |
|
405 |
} |
|
406 |
} |
|
407 |
||
408 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
409 |
* ModulePackages attribute. |
36511 | 410 |
* |
411 |
* <pre> {@code |
|
412 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
413 |
* ModulePackages_attribute { |
36511 | 414 |
* // index to CONSTANT_utf8_info structure in constant pool representing |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
415 |
* // the string "ModulePackages" |
36511 | 416 |
* u2 attribute_name_index; |
417 |
* u4 attribute_length; |
|
418 |
* |
|
419 |
* // the number of entries in the packages table |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
420 |
* u2 packages_count; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
421 |
* { // index to CONSTANT_Package_info structure with the package name |
36511 | 422 |
* u2 package_index |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
423 |
* } packages[package_count]; |
36511 | 424 |
* |
425 |
* }</pre> |
|
426 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
427 |
public static class ModulePackagesAttribute extends Attribute { |
36511 | 428 |
private final Set<String> packages; |
429 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
430 |
public ModulePackagesAttribute(Set<String> packages) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
431 |
super(MODULE_PACKAGES); |
36511 | 432 |
this.packages = packages; |
433 |
} |
|
434 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
435 |
public ModulePackagesAttribute() { |
36511 | 436 |
this(null); |
437 |
} |
|
438 |
||
439 |
@Override |
|
440 |
protected Attribute read(ClassReader cr, |
|
441 |
int off, |
|
442 |
int len, |
|
443 |
char[] buf, |
|
444 |
int codeOff, |
|
445 |
Label[] labels) |
|
446 |
{ |
|
447 |
// package count |
|
448 |
int package_count = cr.readUnsignedShort(off); |
|
449 |
off += 2; |
|
450 |
||
451 |
// packages |
|
452 |
Set<String> packages = new HashSet<>(); |
|
453 |
for (int i=0; i<package_count; i++) { |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
454 |
String pkg = cr.readPackage(off, buf).replace('/', '.'); |
36511 | 455 |
packages.add(pkg); |
456 |
off += 2; |
|
457 |
} |
|
458 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
459 |
return new ModulePackagesAttribute(packages); |
36511 | 460 |
} |
461 |
||
462 |
@Override |
|
463 |
protected ByteVector write(ClassWriter cw, |
|
464 |
byte[] code, |
|
465 |
int len, |
|
466 |
int maxStack, |
|
467 |
int maxLocals) |
|
468 |
{ |
|
469 |
assert packages != null; |
|
470 |
||
471 |
ByteVector attr = new ByteVector(); |
|
472 |
||
473 |
// package_count |
|
474 |
attr.putShort(packages.size()); |
|
475 |
||
476 |
// packages |
|
477 |
packages.stream() |
|
478 |
.map(p -> p.replace('.', '/')) |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
479 |
.forEach(p -> attr.putShort(cw.newPackage(p))); |
36511 | 480 |
|
481 |
return attr; |
|
482 |
} |
|
483 |
||
484 |
} |
|
485 |
||
486 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
487 |
* ModuleMainClass attribute. |
36511 | 488 |
* |
489 |
* <pre> {@code |
|
490 |
* |
|
491 |
* MainClass_attribute { |
|
492 |
* // index to CONSTANT_utf8_info structure in constant pool representing |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
493 |
* // the string "ModuleMainClass" |
36511 | 494 |
* u2 attribute_name_index; |
495 |
* u4 attribute_length; |
|
496 |
* |
|
497 |
* // index to CONSTANT_Class_info structure with the main class name |
|
498 |
* u2 main_class_index; |
|
499 |
* } |
|
500 |
* |
|
501 |
* } </pre> |
|
502 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
503 |
public static class ModuleMainClassAttribute extends Attribute { |
36511 | 504 |
private final String mainClass; |
505 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
506 |
public ModuleMainClassAttribute(String mainClass) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
507 |
super(MODULE_MAIN_CLASS); |
36511 | 508 |
this.mainClass = mainClass; |
509 |
} |
|
510 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
511 |
public ModuleMainClassAttribute() { |
36511 | 512 |
this(null); |
513 |
} |
|
514 |
||
515 |
@Override |
|
516 |
protected Attribute read(ClassReader cr, |
|
517 |
int off, |
|
518 |
int len, |
|
519 |
char[] buf, |
|
520 |
int codeOff, |
|
521 |
Label[] labels) |
|
522 |
{ |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
523 |
String value = cr.readClass(off, buf).replace('/', '.'); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
524 |
return new ModuleMainClassAttribute(value); |
36511 | 525 |
} |
526 |
||
527 |
@Override |
|
528 |
protected ByteVector write(ClassWriter cw, |
|
529 |
byte[] code, |
|
530 |
int len, |
|
531 |
int maxStack, |
|
532 |
int maxLocals) |
|
533 |
{ |
|
534 |
ByteVector attr = new ByteVector(); |
|
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
535 |
int index = cw.newClass(mainClass.replace('.', '/')); |
36511 | 536 |
attr.putShort(index); |
537 |
return attr; |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
542 |
* ModuleTarget attribute. |
36511 | 543 |
* |
544 |
* <pre> {@code |
|
545 |
* |
|
546 |
* TargetPlatform_attribute { |
|
547 |
* // index to CONSTANT_utf8_info structure in constant pool representing |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
548 |
* // the string "ModuleTarget" |
36511 | 549 |
* u2 attribute_name_index; |
550 |
* u4 attribute_length; |
|
551 |
* |
|
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
552 |
* // index to CONSTANT_utf8_info structure with the target platform |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
553 |
* u2 target_platform_index; |
36511 | 554 |
* } |
555 |
* |
|
556 |
* } </pre> |
|
557 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
558 |
public static class ModuleTargetAttribute extends Attribute { |
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
559 |
private final String targetPlatform; |
36511 | 560 |
|
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
561 |
public ModuleTargetAttribute(String targetPlatform) { |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
562 |
super(MODULE_TARGET); |
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
563 |
this.targetPlatform = targetPlatform; |
36511 | 564 |
} |
565 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
566 |
public ModuleTargetAttribute() { |
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
567 |
this(null); |
44359
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
568 |
} |
c6761862ca0b
8174823: Module system implementation refresh (3/2017)
alanb
parents:
43712
diff
changeset
|
569 |
|
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
570 |
public String targetPlatform() { |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
571 |
return targetPlatform; |
36511 | 572 |
} |
573 |
||
574 |
@Override |
|
575 |
protected Attribute read(ClassReader cr, |
|
576 |
int off, |
|
577 |
int len, |
|
578 |
char[] buf, |
|
579 |
int codeOff, |
|
580 |
Label[] labels) |
|
581 |
{ |
|
582 |
||
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
583 |
String targetPlatform = null; |
36511 | 584 |
|
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
585 |
int target_platform_index = cr.readUnsignedShort(off); |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
586 |
if (target_platform_index != 0) |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
587 |
targetPlatform = cr.readUTF8(off, buf); |
36511 | 588 |
off += 2; |
589 |
||
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
590 |
return new ModuleTargetAttribute(targetPlatform); |
36511 | 591 |
} |
592 |
||
593 |
@Override |
|
594 |
protected ByteVector write(ClassWriter cw, |
|
595 |
byte[] code, |
|
596 |
int len, |
|
597 |
int maxStack, |
|
598 |
int maxLocals) |
|
599 |
{ |
|
600 |
ByteVector attr = new ByteVector(); |
|
601 |
||
45004
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
602 |
int target_platform_index = 0; |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
603 |
if (targetPlatform != null && targetPlatform.length() > 0) |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
604 |
target_platform_index = cw.newUTF8(targetPlatform); |
ea3137042a61
8178380: Module system implementation refresh (5/2017)
alanb
parents:
44359
diff
changeset
|
605 |
attr.putShort(target_platform_index); |
36511 | 606 |
|
607 |
return attr; |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
612 |
* ModuleHashes attribute. |
36511 | 613 |
* |
614 |
* <pre> {@code |
|
615 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
616 |
* ModuleHashes_attribute { |
36511 | 617 |
* // index to CONSTANT_utf8_info structure in constant pool representing |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
618 |
* // the string "ModuleHashes" |
36511 | 619 |
* u2 attribute_name_index; |
620 |
* u4 attribute_length; |
|
621 |
* |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
622 |
* // index to CONSTANT_utf8_info structure with algorithm name |
36511 | 623 |
* u2 algorithm_index; |
624 |
* |
|
625 |
* // the number of entries in the hashes table |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
626 |
* u2 hashes_count; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
627 |
* { u2 module_name_index (index to CONSTANT_Module_info structure) |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
628 |
* u2 hash_length; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
629 |
* u1 hash[hash_length]; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
630 |
* } hashes[hashes_count]; |
36511 | 631 |
* |
632 |
* } </pre> |
|
633 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
634 |
static class ModuleHashesAttribute extends Attribute { |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
635 |
private final ModuleHashes hashes; |
36511 | 636 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
637 |
ModuleHashesAttribute(ModuleHashes hashes) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
638 |
super(MODULE_HASHES); |
36511 | 639 |
this.hashes = hashes; |
640 |
} |
|
641 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
642 |
ModuleHashesAttribute() { |
36511 | 643 |
this(null); |
644 |
} |
|
645 |
||
646 |
@Override |
|
647 |
protected Attribute read(ClassReader cr, |
|
648 |
int off, |
|
649 |
int len, |
|
650 |
char[] buf, |
|
651 |
int codeOff, |
|
652 |
Label[] labels) |
|
653 |
{ |
|
654 |
String algorithm = cr.readUTF8(off, buf); |
|
655 |
off += 2; |
|
656 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
657 |
int hashes_count = cr.readUnsignedShort(off); |
36511 | 658 |
off += 2; |
659 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
660 |
Map<String, byte[]> map = new HashMap<>(); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
661 |
for (int i=0; i<hashes_count; i++) { |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
662 |
String mn = cr.readModule(off, buf); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
663 |
off += 2; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
664 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
665 |
int hash_length = cr.readUnsignedShort(off); |
36511 | 666 |
off += 2; |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
667 |
byte[] hash = new byte[hash_length]; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
668 |
for (int j=0; j<hash_length; j++) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
669 |
hash[j] = (byte) (0xff & cr.readByte(off+j)); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
670 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
671 |
off += hash_length; |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
672 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
673 |
map.put(mn, hash); |
36511 | 674 |
} |
675 |
||
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
676 |
ModuleHashes hashes = new ModuleHashes(algorithm, map); |
36511 | 677 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
678 |
return new ModuleHashesAttribute(hashes); |
36511 | 679 |
} |
680 |
||
681 |
@Override |
|
682 |
protected ByteVector write(ClassWriter cw, |
|
683 |
byte[] code, |
|
684 |
int len, |
|
685 |
int maxStack, |
|
686 |
int maxLocals) |
|
687 |
{ |
|
688 |
ByteVector attr = new ByteVector(); |
|
689 |
||
690 |
int index = cw.newUTF8(hashes.algorithm()); |
|
691 |
attr.putShort(index); |
|
692 |
||
693 |
Set<String> names = hashes.names(); |
|
694 |
attr.putShort(names.size()); |
|
695 |
||
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
696 |
for (String mn : names) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
697 |
byte[] hash = hashes.hashFor(mn); |
36511 | 698 |
assert hash != null; |
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
699 |
attr.putShort(cw.newModule(mn)); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
700 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
701 |
attr.putShort(hash.length); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
702 |
for (byte b: hash) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
703 |
attr.putByte(b); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37779
diff
changeset
|
704 |
} |
36511 | 705 |
} |
706 |
||
707 |
return attr; |
|
708 |
} |
|
709 |
} |
|
710 |
||
42703
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
711 |
/** |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
712 |
* ModuleResolution_attribute { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
713 |
* u2 attribute_name_index; // "ModuleResolution" |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
714 |
* u4 attribute_length; // 2 |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
715 |
* u2 resolution_flags; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
716 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
717 |
* The value of the resolution_flags item is a mask of flags used to denote |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
718 |
* properties of module resolution. The flags are as follows: |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
719 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
720 |
* // Optional |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
721 |
* 0x0001 (DO_NOT_RESOLVE_BY_DEFAULT) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
722 |
* |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
723 |
* // At most one of: |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
724 |
* 0x0002 (WARN_DEPRECATED) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
725 |
* 0x0004 (WARN_DEPRECATED_FOR_REMOVAL) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
726 |
* 0x0008 (WARN_INCUBATING) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
727 |
*/ |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
728 |
static class ModuleResolutionAttribute extends Attribute { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
729 |
private final int value; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
730 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
731 |
ModuleResolutionAttribute() { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
732 |
super(MODULE_RESOLUTION); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
733 |
value = 0; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
734 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
735 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
736 |
ModuleResolutionAttribute(int value) { |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
737 |
super(MODULE_RESOLUTION); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
738 |
this.value = value; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
739 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
740 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
741 |
@Override |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
742 |
protected Attribute read(ClassReader cr, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
743 |
int off, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
744 |
int len, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
745 |
char[] buf, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
746 |
int codeOff, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
747 |
Label[] labels) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
748 |
{ |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
749 |
int flags = cr.readUnsignedShort(off); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
750 |
return new ModuleResolutionAttribute(flags); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
751 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
752 |
|
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
753 |
@Override |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
754 |
protected ByteVector write(ClassWriter cw, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
755 |
byte[] code, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
756 |
int len, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
757 |
int maxStack, |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
758 |
int maxLocals) |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
759 |
{ |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
760 |
ByteVector attr = new ByteVector(); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
761 |
attr.putShort(value); |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
762 |
return attr; |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
763 |
} |
20c39ea4a507
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42338
diff
changeset
|
764 |
} |
36511 | 765 |
} |