43972
|
1 |
/*
|
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
package org.graalvm.compiler.nodes.graphbuilderconf;
|
|
24 |
|
|
25 |
import static java.lang.String.format;
|
46459
|
26 |
import static org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.LateClassPlugins.CLOSED_LATE_CLASS_PLUGIN;
|
43972
|
27 |
|
46459
|
28 |
import java.lang.reflect.Constructor;
|
43972
|
29 |
import java.lang.reflect.Method;
|
|
30 |
import java.lang.reflect.Modifier;
|
|
31 |
import java.lang.reflect.Type;
|
|
32 |
import java.util.ArrayList;
|
|
33 |
import java.util.Arrays;
|
46459
|
34 |
import java.util.Collections;
|
43972
|
35 |
import java.util.List;
|
|
36 |
import java.util.Map;
|
46459
|
37 |
|
48861
|
38 |
import org.graalvm.collections.EconomicMap;
|
|
39 |
import org.graalvm.collections.Equivalence;
|
|
40 |
import org.graalvm.collections.MapCursor;
|
|
41 |
import org.graalvm.collections.Pair;
|
|
42 |
import org.graalvm.collections.UnmodifiableEconomicMap;
|
|
43 |
import org.graalvm.collections.UnmodifiableMapCursor;
|
43972
|
44 |
import org.graalvm.compiler.api.replacements.MethodSubstitution;
|
|
45 |
import org.graalvm.compiler.api.replacements.MethodSubstitutionRegistry;
|
|
46 |
import org.graalvm.compiler.bytecode.BytecodeProvider;
|
46459
|
47 |
import org.graalvm.compiler.debug.Assertions;
|
43972
|
48 |
import org.graalvm.compiler.debug.GraalError;
|
|
49 |
import org.graalvm.compiler.graph.Node;
|
|
50 |
import org.graalvm.compiler.graph.iterators.NodeIterable;
|
|
51 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
52 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver;
|
|
53 |
|
|
54 |
import jdk.vm.ci.meta.MetaUtil;
|
|
55 |
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
46459
|
56 |
import jdk.vm.ci.meta.ResolvedJavaType;
|
|
57 |
import jdk.vm.ci.meta.Signature;
|
43972
|
58 |
|
|
59 |
/**
|
|
60 |
* Manages a set of {@link InvocationPlugin}s.
|
46459
|
61 |
*
|
|
62 |
* Most plugins are registered during initialization (i.e., before
|
|
63 |
* {@link #lookupInvocation(ResolvedJavaMethod)} or {@link #getBindings} is called). These
|
|
64 |
* registrations can be made with {@link Registration},
|
|
65 |
* {@link #register(InvocationPlugin, String, String, Type...)},
|
|
66 |
* {@link #register(InvocationPlugin, Type, String, Type...)} or
|
|
67 |
* {@link #registerOptional(InvocationPlugin, Type, String, Type...)}. Initialization is not
|
|
68 |
* thread-safe and so must only be performed by a single thread.
|
|
69 |
*
|
|
70 |
* Plugins that are not guaranteed to be made during initialization must use
|
|
71 |
* {@link LateRegistration}.
|
43972
|
72 |
*/
|
|
73 |
public class InvocationPlugins {
|
|
74 |
|
|
75 |
public static class InvocationPluginReceiver implements InvocationPlugin.Receiver {
|
|
76 |
private final GraphBuilderContext parser;
|
|
77 |
private ValueNode[] args;
|
|
78 |
private ValueNode value;
|
|
79 |
|
|
80 |
public InvocationPluginReceiver(GraphBuilderContext parser) {
|
|
81 |
this.parser = parser;
|
|
82 |
}
|
|
83 |
|
|
84 |
@Override
|
|
85 |
public ValueNode get(boolean performNullCheck) {
|
|
86 |
assert args != null : "Cannot get the receiver of a static method";
|
|
87 |
if (!performNullCheck) {
|
|
88 |
return args[0];
|
|
89 |
}
|
|
90 |
if (value == null) {
|
|
91 |
value = parser.nullCheckedValue(args[0]);
|
|
92 |
if (value != args[0]) {
|
|
93 |
args[0] = value;
|
|
94 |
}
|
|
95 |
}
|
|
96 |
return value;
|
|
97 |
}
|
|
98 |
|
|
99 |
@Override
|
|
100 |
public boolean isConstant() {
|
|
101 |
return args[0].isConstant();
|
|
102 |
}
|
|
103 |
|
|
104 |
public InvocationPluginReceiver init(ResolvedJavaMethod targetMethod, ValueNode[] newArgs) {
|
|
105 |
if (!targetMethod.isStatic()) {
|
|
106 |
this.args = newArgs;
|
|
107 |
this.value = null;
|
|
108 |
return this;
|
|
109 |
}
|
|
110 |
return null;
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
/**
|
48861
|
115 |
* A symbol for an already resolved method.
|
|
116 |
*/
|
|
117 |
public static class ResolvedJavaSymbol implements Type {
|
|
118 |
private final ResolvedJavaType resolved;
|
|
119 |
|
|
120 |
public ResolvedJavaSymbol(ResolvedJavaType type) {
|
|
121 |
this.resolved = type;
|
|
122 |
}
|
|
123 |
|
|
124 |
public ResolvedJavaType getResolved() {
|
|
125 |
return resolved;
|
|
126 |
}
|
|
127 |
|
|
128 |
@Override
|
|
129 |
public String toString() {
|
|
130 |
return resolved.toJavaName();
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
/**
|
43972
|
135 |
* A symbol that is lazily {@linkplain OptionalLazySymbol#resolve() resolved} to a {@link Type}.
|
|
136 |
*/
|
|
137 |
static class OptionalLazySymbol implements Type {
|
|
138 |
private static final Class<?> MASK_NULL = OptionalLazySymbol.class;
|
|
139 |
private final String name;
|
|
140 |
private Class<?> resolved;
|
|
141 |
|
|
142 |
OptionalLazySymbol(String name) {
|
|
143 |
this.name = name;
|
|
144 |
}
|
|
145 |
|
|
146 |
@Override
|
|
147 |
public String getTypeName() {
|
|
148 |
return name;
|
|
149 |
}
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Gets the resolved {@link Class} corresponding to this symbol or {@code null} if
|
|
153 |
* resolution fails.
|
|
154 |
*/
|
|
155 |
public Class<?> resolve() {
|
|
156 |
if (resolved == null) {
|
|
157 |
Class<?> resolvedOrNull = resolveClass(name, true);
|
|
158 |
resolved = resolvedOrNull == null ? MASK_NULL : resolvedOrNull;
|
|
159 |
}
|
|
160 |
return resolved == MASK_NULL ? null : resolved;
|
|
161 |
}
|
|
162 |
|
|
163 |
@Override
|
|
164 |
public String toString() {
|
|
165 |
return name;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Utility for {@linkplain InvocationPlugins#register(InvocationPlugin, Class, String, Class...)
|
|
171 |
* registration} of invocation plugins.
|
|
172 |
*/
|
|
173 |
public static class Registration implements MethodSubstitutionRegistry {
|
|
174 |
|
|
175 |
private final InvocationPlugins plugins;
|
|
176 |
private final Type declaringType;
|
|
177 |
private final BytecodeProvider methodSubstitutionBytecodeProvider;
|
|
178 |
private boolean allowOverwrite;
|
|
179 |
|
|
180 |
@Override
|
|
181 |
public Class<?> getReceiverType() {
|
|
182 |
return Receiver.class;
|
|
183 |
}
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Creates an object for registering {@link InvocationPlugin}s for methods declared by a
|
|
187 |
* given class.
|
|
188 |
*
|
|
189 |
* @param plugins where to register the plugins
|
|
190 |
* @param declaringType the class declaring the methods for which plugins will be registered
|
|
191 |
* via this object
|
|
192 |
*/
|
|
193 |
public Registration(InvocationPlugins plugins, Type declaringType) {
|
|
194 |
this.plugins = plugins;
|
|
195 |
this.declaringType = declaringType;
|
|
196 |
this.methodSubstitutionBytecodeProvider = null;
|
|
197 |
}
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Creates an object for registering {@link InvocationPlugin}s for methods declared by a
|
|
201 |
* given class.
|
|
202 |
*
|
|
203 |
* @param plugins where to register the plugins
|
|
204 |
* @param declaringType the class declaring the methods for which plugins will be registered
|
|
205 |
* via this object
|
|
206 |
* @param methodSubstitutionBytecodeProvider provider used to get the bytecodes to parse for
|
|
207 |
* method substitutions
|
|
208 |
*/
|
|
209 |
public Registration(InvocationPlugins plugins, Type declaringType, BytecodeProvider methodSubstitutionBytecodeProvider) {
|
|
210 |
this.plugins = plugins;
|
|
211 |
this.declaringType = declaringType;
|
|
212 |
this.methodSubstitutionBytecodeProvider = methodSubstitutionBytecodeProvider;
|
|
213 |
}
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Creates an object for registering {@link InvocationPlugin}s for methods declared by a
|
|
217 |
* given class.
|
|
218 |
*
|
|
219 |
* @param plugins where to register the plugins
|
|
220 |
* @param declaringClassName the name of the class class declaring the methods for which
|
|
221 |
* plugins will be registered via this object
|
|
222 |
* @param methodSubstitutionBytecodeProvider provider used to get the bytecodes to parse for
|
|
223 |
* method substitutions
|
|
224 |
*/
|
|
225 |
public Registration(InvocationPlugins plugins, String declaringClassName, BytecodeProvider methodSubstitutionBytecodeProvider) {
|
|
226 |
this.plugins = plugins;
|
|
227 |
this.declaringType = new OptionalLazySymbol(declaringClassName);
|
|
228 |
this.methodSubstitutionBytecodeProvider = methodSubstitutionBytecodeProvider;
|
|
229 |
}
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Configures this registration to allow or disallow overwriting of invocation plugins.
|
|
233 |
*/
|
|
234 |
public Registration setAllowOverwrite(boolean allowOverwrite) {
|
|
235 |
this.allowOverwrite = allowOverwrite;
|
|
236 |
return this;
|
|
237 |
}
|
|
238 |
|
|
239 |
/**
|
|
240 |
* Registers a plugin for a method with no arguments.
|
|
241 |
*
|
|
242 |
* @param name the name of the method
|
|
243 |
* @param plugin the plugin to be registered
|
|
244 |
*/
|
|
245 |
public void register0(String name, InvocationPlugin plugin) {
|
|
246 |
plugins.register(plugin, false, allowOverwrite, declaringType, name);
|
|
247 |
}
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Registers a plugin for a method with 1 argument.
|
|
251 |
*
|
|
252 |
* @param name the name of the method
|
|
253 |
* @param plugin the plugin to be registered
|
|
254 |
*/
|
|
255 |
public void register1(String name, Type arg, InvocationPlugin plugin) {
|
|
256 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg);
|
|
257 |
}
|
|
258 |
|
|
259 |
/**
|
|
260 |
* Registers a plugin for a method with 2 arguments.
|
|
261 |
*
|
|
262 |
* @param name the name of the method
|
|
263 |
* @param plugin the plugin to be registered
|
|
264 |
*/
|
|
265 |
public void register2(String name, Type arg1, Type arg2, InvocationPlugin plugin) {
|
|
266 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2);
|
|
267 |
}
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Registers a plugin for a method with 3 arguments.
|
|
271 |
*
|
|
272 |
* @param name the name of the method
|
|
273 |
* @param plugin the plugin to be registered
|
|
274 |
*/
|
|
275 |
public void register3(String name, Type arg1, Type arg2, Type arg3, InvocationPlugin plugin) {
|
|
276 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2, arg3);
|
|
277 |
}
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Registers a plugin for a method with 4 arguments.
|
|
281 |
*
|
|
282 |
* @param name the name of the method
|
|
283 |
* @param plugin the plugin to be registered
|
|
284 |
*/
|
|
285 |
public void register4(String name, Type arg1, Type arg2, Type arg3, Type arg4, InvocationPlugin plugin) {
|
|
286 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2, arg3, arg4);
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Registers a plugin for a method with 5 arguments.
|
|
291 |
*
|
|
292 |
* @param name the name of the method
|
|
293 |
* @param plugin the plugin to be registered
|
|
294 |
*/
|
|
295 |
public void register5(String name, Type arg1, Type arg2, Type arg3, Type arg4, Type arg5, InvocationPlugin plugin) {
|
|
296 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2, arg3, arg4, arg5);
|
|
297 |
}
|
|
298 |
|
|
299 |
/**
|
44836
|
300 |
* Registers a plugin for a method with 6 arguments.
|
|
301 |
*
|
|
302 |
* @param name the name of the method
|
|
303 |
* @param plugin the plugin to be registered
|
|
304 |
*/
|
|
305 |
public void register6(String name, Type arg1, Type arg2, Type arg3, Type arg4, Type arg5, Type arg6, InvocationPlugin plugin) {
|
|
306 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2, arg3, arg4, arg5, arg6);
|
|
307 |
}
|
|
308 |
|
|
309 |
/**
|
|
310 |
* Registers a plugin for a method with 7 arguments.
|
|
311 |
*
|
|
312 |
* @param name the name of the method
|
|
313 |
* @param plugin the plugin to be registered
|
|
314 |
*/
|
|
315 |
public void register7(String name, Type arg1, Type arg2, Type arg3, Type arg4, Type arg5, Type arg6, Type arg7, InvocationPlugin plugin) {
|
|
316 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
|
317 |
}
|
|
318 |
|
|
319 |
/**
|
43972
|
320 |
* Registers a plugin for an optional method with no arguments.
|
|
321 |
*
|
|
322 |
* @param name the name of the method
|
|
323 |
* @param plugin the plugin to be registered
|
|
324 |
*/
|
|
325 |
public void registerOptional0(String name, InvocationPlugin plugin) {
|
|
326 |
plugins.register(plugin, true, allowOverwrite, declaringType, name);
|
|
327 |
}
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Registers a plugin for an optional method with 1 argument.
|
|
331 |
*
|
|
332 |
* @param name the name of the method
|
|
333 |
* @param plugin the plugin to be registered
|
|
334 |
*/
|
|
335 |
public void registerOptional1(String name, Type arg, InvocationPlugin plugin) {
|
|
336 |
plugins.register(plugin, true, allowOverwrite, declaringType, name, arg);
|
|
337 |
}
|
|
338 |
|
|
339 |
/**
|
|
340 |
* Registers a plugin for an optional method with 2 arguments.
|
|
341 |
*
|
|
342 |
* @param name the name of the method
|
|
343 |
* @param plugin the plugin to be registered
|
|
344 |
*/
|
|
345 |
public void registerOptional2(String name, Type arg1, Type arg2, InvocationPlugin plugin) {
|
|
346 |
plugins.register(plugin, true, allowOverwrite, declaringType, name, arg1, arg2);
|
|
347 |
}
|
|
348 |
|
|
349 |
/**
|
|
350 |
* Registers a plugin for an optional method with 3 arguments.
|
|
351 |
*
|
|
352 |
* @param name the name of the method
|
|
353 |
* @param plugin the plugin to be registered
|
|
354 |
*/
|
|
355 |
public void registerOptional3(String name, Type arg1, Type arg2, Type arg3, InvocationPlugin plugin) {
|
|
356 |
plugins.register(plugin, true, allowOverwrite, declaringType, name, arg1, arg2, arg3);
|
|
357 |
}
|
|
358 |
|
|
359 |
/**
|
|
360 |
* Registers a plugin for an optional method with 4 arguments.
|
|
361 |
*
|
|
362 |
* @param name the name of the method
|
|
363 |
* @param plugin the plugin to be registered
|
|
364 |
*/
|
|
365 |
public void registerOptional4(String name, Type arg1, Type arg2, Type arg3, Type arg4, InvocationPlugin plugin) {
|
|
366 |
plugins.register(plugin, true, allowOverwrite, declaringType, name, arg1, arg2, arg3, arg4);
|
|
367 |
}
|
|
368 |
|
|
369 |
/**
|
|
370 |
* Registers a plugin that implements a method based on the bytecode of a substitute method.
|
|
371 |
*
|
|
372 |
* @param substituteDeclaringClass the class declaring the substitute method
|
|
373 |
* @param name the name of both the original and substitute method
|
|
374 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be
|
|
375 |
* the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method
|
|
376 |
* is non-static. Upon returning, element 0 will have been rewritten to
|
|
377 |
* {@code declaringClass}
|
|
378 |
*/
|
|
379 |
@Override
|
|
380 |
public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, Type... argumentTypes) {
|
|
381 |
registerMethodSubstitution(substituteDeclaringClass, name, name, argumentTypes);
|
|
382 |
}
|
|
383 |
|
|
384 |
/**
|
|
385 |
* Registers a plugin that implements a method based on the bytecode of a substitute method.
|
|
386 |
*
|
|
387 |
* @param substituteDeclaringClass the class declaring the substitute method
|
|
388 |
* @param name the name of both the original method
|
|
389 |
* @param substituteName the name of the substitute method
|
|
390 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be
|
|
391 |
* the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method
|
|
392 |
* is non-static. Upon returning, element 0 will have been rewritten to
|
|
393 |
* {@code declaringClass}
|
|
394 |
*/
|
|
395 |
@Override
|
|
396 |
public void registerMethodSubstitution(Class<?> substituteDeclaringClass, String name, String substituteName, Type... argumentTypes) {
|
44836
|
397 |
MethodSubstitutionPlugin plugin = createMethodSubstitution(substituteDeclaringClass, substituteName, argumentTypes);
|
|
398 |
plugins.register(plugin, false, allowOverwrite, declaringType, name, argumentTypes);
|
|
399 |
}
|
|
400 |
|
|
401 |
public MethodSubstitutionPlugin createMethodSubstitution(Class<?> substituteDeclaringClass, String substituteName, Type... argumentTypes) {
|
43972
|
402 |
assert methodSubstitutionBytecodeProvider != null : "Registration used for method substitutions requires a non-null methodSubstitutionBytecodeProvider";
|
|
403 |
MethodSubstitutionPlugin plugin = new MethodSubstitutionPlugin(methodSubstitutionBytecodeProvider, substituteDeclaringClass, substituteName, argumentTypes);
|
44836
|
404 |
return plugin;
|
43972
|
405 |
}
|
44836
|
406 |
|
43972
|
407 |
}
|
|
408 |
|
|
409 |
/**
|
46459
|
410 |
* Utility for registering plugins after Graal may have been initialized. Registrations made via
|
|
411 |
* this class are not finalized until {@link #close} is called.
|
43972
|
412 |
*/
|
46459
|
413 |
public static class LateRegistration implements AutoCloseable {
|
|
414 |
|
|
415 |
private InvocationPlugins plugins;
|
|
416 |
private final List<Binding> bindings = new ArrayList<>();
|
|
417 |
private final Type declaringType;
|
|
418 |
|
|
419 |
/**
|
|
420 |
* Creates an object for registering {@link InvocationPlugin}s for methods declared by a
|
|
421 |
* given class.
|
|
422 |
*
|
|
423 |
* @param plugins where to register the plugins
|
|
424 |
* @param declaringType the class declaring the methods for which plugins will be registered
|
|
425 |
* via this object
|
|
426 |
*/
|
|
427 |
public LateRegistration(InvocationPlugins plugins, Type declaringType) {
|
|
428 |
this.plugins = plugins;
|
|
429 |
this.declaringType = declaringType;
|
|
430 |
}
|
43972
|
431 |
|
46459
|
432 |
/**
|
|
433 |
* Registers an invocation plugin for a given method. There must be no plugin currently
|
|
434 |
* registered for {@code method}.
|
|
435 |
*
|
|
436 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be
|
|
437 |
* the {@link Class} value for {@link InvocationPlugin.Receiver} iff the method
|
|
438 |
* is non-static. Upon returning, element 0 will have been rewritten to
|
|
439 |
* {@code declaringClass}
|
|
440 |
*/
|
|
441 |
public void register(InvocationPlugin plugin, String name, Type... argumentTypes) {
|
|
442 |
boolean isStatic = argumentTypes.length == 0 || argumentTypes[0] != InvocationPlugin.Receiver.class;
|
|
443 |
if (!isStatic) {
|
|
444 |
argumentTypes[0] = declaringType;
|
|
445 |
}
|
|
446 |
|
|
447 |
assert isStatic || argumentTypes[0] == declaringType;
|
|
448 |
Binding binding = new Binding(plugin, isStatic, name, argumentTypes);
|
|
449 |
bindings.add(binding);
|
|
450 |
|
|
451 |
assert Checks.check(this.plugins, declaringType, binding);
|
|
452 |
assert Checks.checkResolvable(false, declaringType, binding);
|
43972
|
453 |
}
|
|
454 |
|
|
455 |
@Override
|
46459
|
456 |
public void close() {
|
|
457 |
assert plugins != null : String.format("Late registrations of invocation plugins for %s is already closed", declaringType);
|
|
458 |
plugins.registerLate(declaringType, bindings);
|
|
459 |
plugins = null;
|
43972
|
460 |
}
|
|
461 |
}
|
|
462 |
|
|
463 |
/**
|
46459
|
464 |
* Associates an {@link InvocationPlugin} with the details of a method it substitutes.
|
43972
|
465 |
*/
|
46459
|
466 |
public static class Binding {
|
|
467 |
/**
|
|
468 |
* The plugin this binding is for.
|
|
469 |
*/
|
|
470 |
public final InvocationPlugin plugin;
|
43972
|
471 |
|
|
472 |
/**
|
46459
|
473 |
* Specifies if the associated method is static.
|
44836
|
474 |
*/
|
46459
|
475 |
public final boolean isStatic;
|
43972
|
476 |
|
46459
|
477 |
/**
|
|
478 |
* The name of the associated method.
|
|
479 |
*/
|
|
480 |
public final String name;
|
43972
|
481 |
|
44836
|
482 |
/**
|
46459
|
483 |
* A partial
|
|
484 |
* <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">method
|
|
485 |
* descriptor</a> for the associated method. The descriptor includes enclosing {@code '('}
|
|
486 |
* and {@code ')'} characters but omits the return type suffix.
|
44836
|
487 |
*/
|
46459
|
488 |
public final String argumentsDescriptor;
|
44836
|
489 |
|
46459
|
490 |
/**
|
|
491 |
* Link in a list of bindings.
|
|
492 |
*/
|
|
493 |
private Binding next;
|
|
494 |
|
|
495 |
Binding(InvocationPlugin data, boolean isStatic, String name, Type... argumentTypes) {
|
|
496 |
this.plugin = data;
|
43972
|
497 |
this.isStatic = isStatic;
|
|
498 |
this.name = name;
|
46459
|
499 |
StringBuilder buf = new StringBuilder();
|
|
500 |
buf.append('(');
|
|
501 |
for (int i = isStatic ? 0 : 1; i < argumentTypes.length; i++) {
|
|
502 |
buf.append(MetaUtil.toInternalName(argumentTypes[i].getTypeName()));
|
43972
|
503 |
}
|
46459
|
504 |
buf.append(')');
|
|
505 |
this.argumentsDescriptor = buf.toString();
|
|
506 |
assert !name.equals("<init>") || !isStatic : this;
|
43972
|
507 |
}
|
|
508 |
|
46459
|
509 |
Binding(ResolvedJavaMethod resolved, InvocationPlugin data) {
|
|
510 |
this.plugin = data;
|
|
511 |
this.isStatic = resolved.isStatic();
|
|
512 |
this.name = resolved.getName();
|
|
513 |
Signature sig = resolved.getSignature();
|
|
514 |
String desc = sig.toMethodDescriptor();
|
|
515 |
assert desc.indexOf(')') != -1 : desc;
|
|
516 |
this.argumentsDescriptor = desc.substring(0, desc.indexOf(')') + 1);
|
|
517 |
assert !name.equals("<init>") || !isStatic : this;
|
43972
|
518 |
}
|
|
519 |
|
|
520 |
@Override
|
|
521 |
public String toString() {
|
46459
|
522 |
return name + argumentsDescriptor;
|
43972
|
523 |
}
|
|
524 |
}
|
|
525 |
|
46459
|
526 |
/**
|
|
527 |
* Plugin registrations for already resolved methods. If non-null, then {@link #registrations}
|
|
528 |
* is null and no further registrations can be made.
|
|
529 |
*/
|
|
530 |
private final UnmodifiableEconomicMap<ResolvedJavaMethod, InvocationPlugin> resolvedRegistrations;
|
43972
|
531 |
|
|
532 |
/**
|
46459
|
533 |
* Map from class names in {@linkplain MetaUtil#toInternalName(String) internal} form to the
|
|
534 |
* invocation plugin bindings for the class. Tf non-null, then {@link #resolvedRegistrations}
|
|
535 |
* will be null.
|
|
536 |
*/
|
|
537 |
private final EconomicMap<String, ClassPlugins> registrations;
|
|
538 |
|
|
539 |
/**
|
|
540 |
* Deferred registrations as well as the guard for delimiting the initial registration phase.
|
|
541 |
* The guard uses double-checked locking which is why this field is {@code volatile}.
|
43972
|
542 |
*/
|
|
543 |
private volatile List<Runnable> deferredRegistrations = new ArrayList<>();
|
|
544 |
|
|
545 |
/**
|
|
546 |
* Adds a {@link Runnable} for doing registration deferred until the first time
|
|
547 |
* {@link #get(ResolvedJavaMethod)} or {@link #closeRegistration()} is called on this object.
|
|
548 |
*/
|
|
549 |
public void defer(Runnable deferrable) {
|
|
550 |
assert deferredRegistrations != null : "registration is closed";
|
|
551 |
deferredRegistrations.add(deferrable);
|
|
552 |
}
|
|
553 |
|
|
554 |
/**
|
46459
|
555 |
* Support for registering plugins once this object may be accessed by multiple threads.
|
|
556 |
*/
|
|
557 |
private volatile LateClassPlugins lateRegistrations;
|
|
558 |
|
|
559 |
/**
|
|
560 |
* Per-class bindings.
|
43972
|
561 |
*/
|
46459
|
562 |
static class ClassPlugins {
|
|
563 |
|
|
564 |
/**
|
|
565 |
* Maps method names to binding lists.
|
|
566 |
*/
|
|
567 |
private final EconomicMap<String, Binding> bindings = EconomicMap.create(Equivalence.DEFAULT);
|
44836
|
568 |
|
46459
|
569 |
/**
|
|
570 |
* Gets the invocation plugin for a given method.
|
|
571 |
*
|
|
572 |
* @return the invocation plugin for {@code method} or {@code null}
|
|
573 |
*/
|
|
574 |
InvocationPlugin get(ResolvedJavaMethod method) {
|
|
575 |
assert !method.isBridge();
|
|
576 |
Binding binding = bindings.get(method.getName());
|
|
577 |
while (binding != null) {
|
|
578 |
if (method.isStatic() == binding.isStatic) {
|
|
579 |
if (method.getSignature().toMethodDescriptor().startsWith(binding.argumentsDescriptor)) {
|
|
580 |
return binding.plugin;
|
|
581 |
}
|
|
582 |
}
|
|
583 |
binding = binding.next;
|
|
584 |
}
|
|
585 |
return null;
|
|
586 |
}
|
43972
|
587 |
|
46459
|
588 |
public void register(Binding binding, boolean allowOverwrite) {
|
|
589 |
if (allowOverwrite) {
|
|
590 |
if (lookup(binding) != null) {
|
|
591 |
register(binding);
|
|
592 |
return;
|
|
593 |
}
|
|
594 |
} else {
|
|
595 |
assert lookup(binding) == null : "a value is already registered for " + binding;
|
|
596 |
}
|
|
597 |
register(binding);
|
|
598 |
}
|
|
599 |
|
|
600 |
InvocationPlugin lookup(Binding binding) {
|
|
601 |
Binding b = bindings.get(binding.name);
|
|
602 |
while (b != null) {
|
|
603 |
if (b.isStatic == binding.isStatic && b.argumentsDescriptor.equals(binding.argumentsDescriptor)) {
|
|
604 |
return b.plugin;
|
|
605 |
}
|
|
606 |
b = b.next;
|
|
607 |
}
|
|
608 |
return null;
|
43972
|
609 |
}
|
|
610 |
|
44836
|
611 |
/**
|
46459
|
612 |
* Registers {@code binding}.
|
44836
|
613 |
*/
|
46459
|
614 |
void register(Binding binding) {
|
|
615 |
Binding head = bindings.get(binding.name);
|
|
616 |
assert binding.next == null;
|
|
617 |
binding.next = head;
|
|
618 |
bindings.put(binding.name, binding);
|
|
619 |
}
|
|
620 |
}
|
43972
|
621 |
|
46459
|
622 |
static class LateClassPlugins extends ClassPlugins {
|
|
623 |
static final String CLOSED_LATE_CLASS_PLUGIN = "-----";
|
|
624 |
private final String className;
|
|
625 |
private final LateClassPlugins next;
|
43972
|
626 |
|
46459
|
627 |
LateClassPlugins(LateClassPlugins next, String className) {
|
|
628 |
assert next == null || next.className != CLOSED_LATE_CLASS_PLUGIN : "Late registration of invocation plugins is closed";
|
|
629 |
this.next = next;
|
|
630 |
this.className = className;
|
43972
|
631 |
}
|
|
632 |
}
|
|
633 |
|
|
634 |
/**
|
46459
|
635 |
* Registers a binding of a method to an invocation plugin.
|
43972
|
636 |
*
|
46459
|
637 |
* @param plugin invocation plugin to be associated with the specified method
|
43972
|
638 |
* @param isStatic specifies if the method is static
|
|
639 |
* @param declaringClass the class declaring the method
|
|
640 |
* @param name the name of the method
|
|
641 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be
|
|
642 |
* {@code declaringClass} iff the method is non-static.
|
|
643 |
* @return an object representing the method
|
|
644 |
*/
|
46459
|
645 |
Binding put(InvocationPlugin plugin, boolean isStatic, boolean allowOverwrite, Type declaringClass, String name, Type... argumentTypes) {
|
|
646 |
assert resolvedRegistrations == null : "registration is closed";
|
|
647 |
String internalName = MetaUtil.toInternalName(declaringClass.getTypeName());
|
43972
|
648 |
assert isStatic || argumentTypes[0] == declaringClass;
|
46459
|
649 |
assert deferredRegistrations != null : "initial registration is closed - use " + LateRegistration.class.getName() + " for late registrations";
|
43972
|
650 |
|
|
651 |
ClassPlugins classPlugins = registrations.get(internalName);
|
|
652 |
if (classPlugins == null) {
|
46459
|
653 |
classPlugins = new ClassPlugins();
|
43972
|
654 |
registrations.put(internalName, classPlugins);
|
|
655 |
}
|
46459
|
656 |
Binding binding = new Binding(plugin, isStatic, name, argumentTypes);
|
|
657 |
classPlugins.register(binding, allowOverwrite);
|
|
658 |
return binding;
|
|
659 |
}
|
|
660 |
|
|
661 |
InvocationPlugin get(ResolvedJavaMethod method) {
|
|
662 |
if (resolvedRegistrations != null) {
|
|
663 |
return resolvedRegistrations.get(method);
|
|
664 |
} else {
|
|
665 |
if (!method.isBridge()) {
|
|
666 |
ResolvedJavaType declaringClass = method.getDeclaringClass();
|
|
667 |
flushDeferrables();
|
|
668 |
String internalName = declaringClass.getName();
|
|
669 |
ClassPlugins classPlugins = registrations.get(internalName);
|
|
670 |
InvocationPlugin res = null;
|
|
671 |
if (classPlugins != null) {
|
|
672 |
res = classPlugins.get(method);
|
|
673 |
}
|
|
674 |
if (res == null) {
|
|
675 |
LateClassPlugins lcp = findLateClassPlugins(internalName);
|
|
676 |
if (lcp != null) {
|
|
677 |
res = lcp.get(method);
|
|
678 |
}
|
|
679 |
}
|
|
680 |
if (res != null) {
|
|
681 |
if (canBeIntrinsified(declaringClass)) {
|
|
682 |
return res;
|
|
683 |
}
|
|
684 |
}
|
|
685 |
if (testExtensions != null) {
|
|
686 |
// Avoid the synchronization in the common case that there
|
|
687 |
// are no test extensions.
|
|
688 |
synchronized (this) {
|
|
689 |
if (testExtensions != null) {
|
|
690 |
List<Binding> bindings = testExtensions.get(internalName);
|
|
691 |
if (bindings != null) {
|
|
692 |
String name = method.getName();
|
|
693 |
String descriptor = method.getSignature().toMethodDescriptor();
|
|
694 |
for (Binding b : bindings) {
|
|
695 |
if (b.isStatic == method.isStatic() &&
|
|
696 |
b.name.equals(name) &&
|
|
697 |
descriptor.startsWith(b.argumentsDescriptor)) {
|
|
698 |
return b.plugin;
|
|
699 |
}
|
|
700 |
}
|
|
701 |
}
|
|
702 |
}
|
|
703 |
}
|
|
704 |
}
|
|
705 |
} else {
|
|
706 |
// Supporting plugins for bridge methods would require including
|
|
707 |
// the return type in the registered signature. Until needed,
|
|
708 |
// this extra complexity is best avoided.
|
|
709 |
}
|
|
710 |
}
|
|
711 |
return null;
|
43972
|
712 |
}
|
|
713 |
|
|
714 |
/**
|
46459
|
715 |
* Determines if methods in a given class can have invocation plugins.
|
|
716 |
*
|
|
717 |
* @param declaringClass the class to test
|
43972
|
718 |
*/
|
48861
|
719 |
public boolean canBeIntrinsified(ResolvedJavaType declaringClass) {
|
46459
|
720 |
return true;
|
44836
|
721 |
}
|
|
722 |
|
46459
|
723 |
LateClassPlugins findLateClassPlugins(String internalClassName) {
|
|
724 |
for (LateClassPlugins lcp = lateRegistrations; lcp != null; lcp = lcp.next) {
|
|
725 |
if (lcp.className.equals(internalClassName)) {
|
|
726 |
return lcp;
|
|
727 |
}
|
43972
|
728 |
}
|
|
729 |
return null;
|
|
730 |
}
|
|
731 |
|
46509
|
732 |
@SuppressWarnings("serial")
|
|
733 |
static class InvocationPlugRegistrationError extends GraalError {
|
|
734 |
InvocationPlugRegistrationError(Throwable cause) {
|
|
735 |
super(cause);
|
|
736 |
}
|
|
737 |
}
|
|
738 |
|
43972
|
739 |
private void flushDeferrables() {
|
|
740 |
if (deferredRegistrations != null) {
|
|
741 |
synchronized (this) {
|
|
742 |
if (deferredRegistrations != null) {
|
46509
|
743 |
try {
|
|
744 |
for (Runnable deferrable : deferredRegistrations) {
|
|
745 |
deferrable.run();
|
|
746 |
}
|
|
747 |
deferredRegistrations = null;
|
|
748 |
} catch (InvocationPlugRegistrationError t) {
|
|
749 |
throw t;
|
|
750 |
} catch (Throwable t) {
|
|
751 |
/*
|
|
752 |
* Something went wrong during registration but it's possible we'll end up
|
|
753 |
* coming back into this code. nulling out deferredRegistrations would just
|
|
754 |
* cause other things to break and rerunning them would cause errors about
|
|
755 |
* already registered plugins, so rethrow the original exception during
|
|
756 |
* later invocations.
|
|
757 |
*/
|
|
758 |
deferredRegistrations.clear();
|
|
759 |
Runnable rethrow = new Runnable() {
|
|
760 |
@Override
|
|
761 |
public void run() {
|
|
762 |
throw new InvocationPlugRegistrationError(t);
|
|
763 |
}
|
|
764 |
};
|
|
765 |
deferredRegistrations.add(rethrow);
|
|
766 |
rethrow.run();
|
43972
|
767 |
}
|
|
768 |
}
|
|
769 |
}
|
46459
|
770 |
}
|
|
771 |
}
|
|
772 |
|
|
773 |
private volatile EconomicMap<String, List<Binding>> testExtensions;
|
|
774 |
|
|
775 |
private static int findBinding(List<Binding> list, Binding key) {
|
|
776 |
for (int i = 0; i < list.size(); i++) {
|
|
777 |
Binding b = list.get(i);
|
|
778 |
if (b.isStatic == key.isStatic && b.name.equals(key.name) && b.argumentsDescriptor.equals(key.argumentsDescriptor)) {
|
|
779 |
return i;
|
|
780 |
}
|
|
781 |
}
|
|
782 |
return -1;
|
|
783 |
}
|
|
784 |
|
|
785 |
/**
|
|
786 |
* Extends the plugins in this object with those from {@code other}. The added plugins should be
|
|
787 |
* {@linkplain #removeTestPlugins(InvocationPlugins) removed} after the test.
|
|
788 |
*
|
|
789 |
* This extension mechanism exists only for tests that want to add extra invocation plugins
|
|
790 |
* after the compiler has been initialized.
|
|
791 |
*
|
|
792 |
* @param ignored if non-null, the bindings from {@code other} already in this object prior to
|
|
793 |
* calling this method are added to this list. These bindings are not added to this
|
|
794 |
* object.
|
|
795 |
*/
|
|
796 |
public synchronized void addTestPlugins(InvocationPlugins other, List<Pair<String, Binding>> ignored) {
|
|
797 |
assert resolvedRegistrations == null : "registration is closed";
|
|
798 |
EconomicMap<String, List<Binding>> otherBindings = other.getBindings(true, false);
|
|
799 |
if (otherBindings.isEmpty()) {
|
|
800 |
return;
|
|
801 |
}
|
|
802 |
if (testExtensions == null) {
|
|
803 |
testExtensions = EconomicMap.create();
|
|
804 |
}
|
|
805 |
MapCursor<String, List<Binding>> c = otherBindings.getEntries();
|
|
806 |
while (c.advance()) {
|
|
807 |
String declaringClass = c.getKey();
|
|
808 |
List<Binding> bindings = testExtensions.get(declaringClass);
|
|
809 |
if (bindings == null) {
|
|
810 |
bindings = new ArrayList<>();
|
|
811 |
testExtensions.put(declaringClass, bindings);
|
|
812 |
}
|
|
813 |
for (Binding b : c.getValue()) {
|
|
814 |
int index = findBinding(bindings, b);
|
|
815 |
if (index != -1) {
|
|
816 |
if (ignored != null) {
|
|
817 |
ignored.add(Pair.create(declaringClass, b));
|
|
818 |
}
|
|
819 |
} else {
|
|
820 |
bindings.add(b);
|
|
821 |
}
|
43972
|
822 |
}
|
|
823 |
}
|
|
824 |
}
|
|
825 |
|
|
826 |
/**
|
46459
|
827 |
* Removes the plugins from {@code other} in this object that were added by
|
|
828 |
* {@link #addTestPlugins}.
|
43972
|
829 |
*/
|
46459
|
830 |
public synchronized void removeTestPlugins(InvocationPlugins other) {
|
|
831 |
assert resolvedRegistrations == null : "registration is closed";
|
|
832 |
if (testExtensions != null) {
|
|
833 |
MapCursor<String, List<Binding>> c = other.getBindings(false).getEntries();
|
|
834 |
while (c.advance()) {
|
|
835 |
String declaringClass = c.getKey();
|
|
836 |
List<Binding> bindings = testExtensions.get(declaringClass);
|
|
837 |
if (bindings != null) {
|
|
838 |
for (Binding b : c.getValue()) {
|
|
839 |
int index = findBinding(bindings, b);
|
|
840 |
if (index != -1) {
|
|
841 |
bindings.remove(index);
|
|
842 |
}
|
|
843 |
}
|
|
844 |
if (bindings.isEmpty()) {
|
|
845 |
testExtensions.removeKey(declaringClass);
|
|
846 |
}
|
|
847 |
}
|
|
848 |
}
|
|
849 |
if (testExtensions.isEmpty()) {
|
|
850 |
testExtensions = null;
|
|
851 |
}
|
44836
|
852 |
}
|
|
853 |
}
|
|
854 |
|
46459
|
855 |
synchronized void registerLate(Type declaringType, List<Binding> bindings) {
|
|
856 |
String internalName = MetaUtil.toInternalName(declaringType.getTypeName());
|
|
857 |
assert findLateClassPlugins(internalName) == null : "Cannot have more than one late registration of invocation plugins for " + internalName;
|
|
858 |
LateClassPlugins lateClassPlugins = new LateClassPlugins(lateRegistrations, internalName);
|
|
859 |
for (Binding b : bindings) {
|
|
860 |
lateClassPlugins.register(b);
|
|
861 |
}
|
|
862 |
lateRegistrations = lateClassPlugins;
|
|
863 |
}
|
|
864 |
|
|
865 |
private synchronized boolean closeLateRegistrations() {
|
|
866 |
if (lateRegistrations == null || lateRegistrations.className != CLOSED_LATE_CLASS_PLUGIN) {
|
|
867 |
lateRegistrations = new LateClassPlugins(lateRegistrations, CLOSED_LATE_CLASS_PLUGIN);
|
|
868 |
}
|
|
869 |
return true;
|
|
870 |
}
|
|
871 |
|
|
872 |
/**
|
|
873 |
* Processes deferred registrations and then closes this object for future registration.
|
|
874 |
*/
|
|
875 |
public void closeRegistration() {
|
|
876 |
assert closeLateRegistrations();
|
|
877 |
flushDeferrables();
|
|
878 |
}
|
|
879 |
|
|
880 |
public boolean isEmpty() {
|
|
881 |
if (resolvedRegistrations != null) {
|
|
882 |
return resolvedRegistrations.isEmpty();
|
|
883 |
}
|
|
884 |
return registrations.size() == 0 && lateRegistrations == null;
|
43972
|
885 |
}
|
|
886 |
|
|
887 |
/**
|
|
888 |
* The plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched} before searching in
|
|
889 |
* this object.
|
|
890 |
*/
|
|
891 |
protected final InvocationPlugins parent;
|
|
892 |
|
46459
|
893 |
/**
|
|
894 |
* Creates a set of invocation plugins with no parent.
|
|
895 |
*/
|
|
896 |
public InvocationPlugins() {
|
|
897 |
this(null);
|
43972
|
898 |
}
|
|
899 |
|
|
900 |
/**
|
46459
|
901 |
* Creates a set of invocation plugins.
|
|
902 |
*
|
|
903 |
* @param parent if non-null, this object will be searched first when looking up plugins
|
43972
|
904 |
*/
|
|
905 |
public InvocationPlugins(InvocationPlugins parent) {
|
46459
|
906 |
InvocationPlugins p = parent;
|
|
907 |
this.parent = p;
|
|
908 |
this.registrations = EconomicMap.create();
|
|
909 |
this.resolvedRegistrations = null;
|
43972
|
910 |
}
|
|
911 |
|
46459
|
912 |
/**
|
|
913 |
* Creates a closed set of invocation plugins for a set of resolved methods. Such an object
|
|
914 |
* cannot have further plugins registered.
|
|
915 |
*/
|
|
916 |
public InvocationPlugins(Map<ResolvedJavaMethod, InvocationPlugin> plugins, InvocationPlugins parent) {
|
43972
|
917 |
this.parent = parent;
|
46459
|
918 |
this.registrations = null;
|
43972
|
919 |
this.deferredRegistrations = null;
|
46459
|
920 |
EconomicMap<ResolvedJavaMethod, InvocationPlugin> map = EconomicMap.create(plugins.size());
|
43972
|
921 |
|
|
922 |
for (Map.Entry<ResolvedJavaMethod, InvocationPlugin> entry : plugins.entrySet()) {
|
46459
|
923 |
map.put(entry.getKey(), entry.getValue());
|
43972
|
924 |
}
|
46459
|
925 |
this.resolvedRegistrations = map;
|
43972
|
926 |
}
|
|
927 |
|
|
928 |
protected void register(InvocationPlugin plugin, boolean isOptional, boolean allowOverwrite, Type declaringClass, String name, Type... argumentTypes) {
|
|
929 |
boolean isStatic = argumentTypes.length == 0 || argumentTypes[0] != InvocationPlugin.Receiver.class;
|
|
930 |
if (!isStatic) {
|
|
931 |
argumentTypes[0] = declaringClass;
|
|
932 |
}
|
46459
|
933 |
Binding binding = put(plugin, isStatic, allowOverwrite, declaringClass, name, argumentTypes);
|
|
934 |
assert Checks.check(this, declaringClass, binding);
|
|
935 |
assert Checks.checkResolvable(isOptional, declaringClass, binding);
|
43972
|
936 |
}
|
|
937 |
|
|
938 |
/**
|
|
939 |
* Registers an invocation plugin for a given method. There must be no plugin currently
|
|
940 |
* registered for {@code method}.
|
|
941 |
*
|
|
942 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be the
|
|
943 |
* {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is
|
|
944 |
* non-static. Upon returning, element 0 will have been rewritten to
|
|
945 |
* {@code declaringClass}
|
|
946 |
*/
|
|
947 |
public void register(InvocationPlugin plugin, Type declaringClass, String name, Type... argumentTypes) {
|
|
948 |
register(plugin, false, false, declaringClass, name, argumentTypes);
|
|
949 |
}
|
|
950 |
|
|
951 |
public void register(InvocationPlugin plugin, String declaringClass, String name, Type... argumentTypes) {
|
|
952 |
register(plugin, false, false, new OptionalLazySymbol(declaringClass), name, argumentTypes);
|
|
953 |
}
|
|
954 |
|
|
955 |
/**
|
|
956 |
* Registers an invocation plugin for a given, optional method. There must be no plugin
|
|
957 |
* currently registered for {@code method}.
|
|
958 |
*
|
|
959 |
* @param argumentTypes the argument types of the method. Element 0 of this array must be the
|
|
960 |
* {@link Class} value for {@link InvocationPlugin.Receiver} iff the method is
|
|
961 |
* non-static. Upon returning, element 0 will have been rewritten to
|
|
962 |
* {@code declaringClass}
|
|
963 |
*/
|
|
964 |
public void registerOptional(InvocationPlugin plugin, Type declaringClass, String name, Type... argumentTypes) {
|
|
965 |
register(plugin, true, false, declaringClass, name, argumentTypes);
|
|
966 |
}
|
|
967 |
|
|
968 |
/**
|
|
969 |
* Gets the plugin for a given method.
|
|
970 |
*
|
|
971 |
* @param method the method to lookup
|
|
972 |
* @return the plugin associated with {@code method} or {@code null} if none exists
|
|
973 |
*/
|
|
974 |
public InvocationPlugin lookupInvocation(ResolvedJavaMethod method) {
|
|
975 |
if (parent != null) {
|
|
976 |
InvocationPlugin plugin = parent.lookupInvocation(method);
|
|
977 |
if (plugin != null) {
|
|
978 |
return plugin;
|
|
979 |
}
|
|
980 |
}
|
|
981 |
return get(method);
|
|
982 |
}
|
|
983 |
|
|
984 |
/**
|
46459
|
985 |
* Gets the set of registered invocation plugins.
|
|
986 |
*
|
|
987 |
* @return a map from class names in {@linkplain MetaUtil#toInternalName(String) internal} form
|
|
988 |
* to the invocation plugin bindings for methods in the class
|
|
989 |
*/
|
|
990 |
public EconomicMap<String, List<Binding>> getBindings(boolean includeParents) {
|
|
991 |
return getBindings(includeParents, true);
|
|
992 |
}
|
|
993 |
|
|
994 |
/**
|
|
995 |
* Gets the set of registered invocation plugins.
|
|
996 |
*
|
|
997 |
* @return a map from class names in {@linkplain MetaUtil#toInternalName(String) internal} form
|
|
998 |
* to the invocation plugin bindings for methods in the class
|
43972
|
999 |
*/
|
46459
|
1000 |
private EconomicMap<String, List<Binding>> getBindings(boolean includeParents, boolean flushDeferrables) {
|
|
1001 |
EconomicMap<String, List<Binding>> res = EconomicMap.create(Equivalence.DEFAULT);
|
|
1002 |
if (parent != null && includeParents) {
|
|
1003 |
res.putAll(parent.getBindings(true, flushDeferrables));
|
43972
|
1004 |
}
|
46459
|
1005 |
if (resolvedRegistrations != null) {
|
|
1006 |
UnmodifiableMapCursor<ResolvedJavaMethod, InvocationPlugin> cursor = resolvedRegistrations.getEntries();
|
|
1007 |
while (cursor.advance()) {
|
|
1008 |
ResolvedJavaMethod method = cursor.getKey();
|
|
1009 |
InvocationPlugin plugin = cursor.getValue();
|
|
1010 |
String type = method.getDeclaringClass().getName();
|
|
1011 |
List<Binding> bindings = res.get(type);
|
|
1012 |
if (bindings == null) {
|
|
1013 |
bindings = new ArrayList<>();
|
|
1014 |
res.put(type, bindings);
|
|
1015 |
}
|
|
1016 |
bindings.add(new Binding(method, plugin));
|
|
1017 |
}
|
|
1018 |
} else {
|
|
1019 |
if (flushDeferrables) {
|
|
1020 |
flushDeferrables();
|
|
1021 |
}
|
|
1022 |
MapCursor<String, ClassPlugins> classes = registrations.getEntries();
|
|
1023 |
while (classes.advance()) {
|
|
1024 |
String type = classes.getKey();
|
|
1025 |
ClassPlugins cp = classes.getValue();
|
|
1026 |
collectBindingsTo(res, type, cp);
|
|
1027 |
}
|
|
1028 |
for (LateClassPlugins lcp = lateRegistrations; lcp != null; lcp = lcp.next) {
|
|
1029 |
String type = lcp.className;
|
|
1030 |
collectBindingsTo(res, type, lcp);
|
|
1031 |
}
|
|
1032 |
if (testExtensions != null) {
|
|
1033 |
// Avoid the synchronization in the common case that there
|
|
1034 |
// are no test extensions.
|
|
1035 |
synchronized (this) {
|
|
1036 |
if (testExtensions != null) {
|
|
1037 |
MapCursor<String, List<Binding>> c = testExtensions.getEntries();
|
|
1038 |
while (c.advance()) {
|
|
1039 |
String name = c.getKey();
|
|
1040 |
List<Binding> bindings = res.get(name);
|
|
1041 |
if (bindings == null) {
|
|
1042 |
bindings = new ArrayList<>();
|
|
1043 |
res.put(name, bindings);
|
|
1044 |
}
|
|
1045 |
bindings.addAll(c.getValue());
|
|
1046 |
}
|
|
1047 |
}
|
|
1048 |
}
|
43972
|
1049 |
}
|
|
1050 |
}
|
|
1051 |
return res;
|
|
1052 |
}
|
|
1053 |
|
46459
|
1054 |
private static void collectBindingsTo(EconomicMap<String, List<Binding>> res, String type, ClassPlugins cp) {
|
|
1055 |
MapCursor<String, Binding> methods = cp.bindings.getEntries();
|
|
1056 |
while (methods.advance()) {
|
|
1057 |
List<Binding> bindings = res.get(type);
|
|
1058 |
if (bindings == null) {
|
|
1059 |
bindings = new ArrayList<>();
|
|
1060 |
res.put(type, bindings);
|
|
1061 |
}
|
|
1062 |
for (Binding b = methods.getValue(); b != null; b = b.next) {
|
|
1063 |
bindings.add(b);
|
|
1064 |
}
|
|
1065 |
}
|
|
1066 |
}
|
|
1067 |
|
43972
|
1068 |
/**
|
|
1069 |
* Gets the invocation plugins {@linkplain #lookupInvocation(ResolvedJavaMethod) searched}
|
|
1070 |
* before searching in this object.
|
|
1071 |
*/
|
|
1072 |
public InvocationPlugins getParent() {
|
|
1073 |
return parent;
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
@Override
|
|
1077 |
public String toString() {
|
46459
|
1078 |
UnmodifiableMapCursor<String, List<Binding>> entries = getBindings(false, false).getEntries();
|
|
1079 |
List<String> all = new ArrayList<>();
|
46344
|
1080 |
while (entries.advance()) {
|
46459
|
1081 |
String c = MetaUtil.internalNameToJava(entries.getKey(), true, false);
|
|
1082 |
for (Binding b : entries.getValue()) {
|
|
1083 |
all.add(c + '.' + b);
|
|
1084 |
}
|
44836
|
1085 |
}
|
46459
|
1086 |
Collections.sort(all);
|
|
1087 |
StringBuilder buf = new StringBuilder();
|
|
1088 |
String nl = String.format("%n");
|
|
1089 |
for (String s : all) {
|
|
1090 |
if (buf.length() != 0) {
|
|
1091 |
buf.append(nl);
|
|
1092 |
}
|
|
1093 |
buf.append(s);
|
43972
|
1094 |
}
|
46459
|
1095 |
if (parent != null) {
|
|
1096 |
if (buf.length() != 0) {
|
|
1097 |
buf.append(nl);
|
|
1098 |
}
|
|
1099 |
buf.append("// parent").append(nl).append(parent);
|
|
1100 |
}
|
|
1101 |
return buf.toString();
|
43972
|
1102 |
}
|
|
1103 |
|
46459
|
1104 |
/**
|
|
1105 |
* Code only used in assertions. Putting this in a separate class reduces class load time.
|
|
1106 |
*/
|
|
1107 |
private static class Checks {
|
44836
|
1108 |
private static final int MAX_ARITY = 7;
|
43972
|
1109 |
/**
|
|
1110 |
* The set of all {@link InvocationPlugin#apply} method signatures.
|
|
1111 |
*/
|
|
1112 |
static final Class<?>[][] SIGS;
|
|
1113 |
|
|
1114 |
static {
|
46762
|
1115 |
if (!Assertions.assertionsEnabled()) {
|
46459
|
1116 |
throw new GraalError("%s must only be used in assertions", Checks.class.getName());
|
|
1117 |
}
|
43972
|
1118 |
ArrayList<Class<?>[]> sigs = new ArrayList<>(MAX_ARITY);
|
|
1119 |
for (Method method : InvocationPlugin.class.getDeclaredMethods()) {
|
|
1120 |
if (!Modifier.isStatic(method.getModifiers()) && method.getName().equals("apply")) {
|
|
1121 |
Class<?>[] sig = method.getParameterTypes();
|
|
1122 |
assert sig[0] == GraphBuilderContext.class;
|
|
1123 |
assert sig[1] == ResolvedJavaMethod.class;
|
|
1124 |
assert sig[2] == InvocationPlugin.Receiver.class;
|
|
1125 |
assert Arrays.asList(sig).subList(3, sig.length).stream().allMatch(c -> c == ValueNode.class);
|
|
1126 |
while (sigs.size() < sig.length - 2) {
|
|
1127 |
sigs.add(null);
|
|
1128 |
}
|
|
1129 |
sigs.set(sig.length - 3, sig);
|
|
1130 |
}
|
|
1131 |
}
|
|
1132 |
assert sigs.indexOf(null) == -1 : format("need to add an apply() method to %s that takes %d %s arguments ", InvocationPlugin.class.getName(), sigs.indexOf(null),
|
|
1133 |
ValueNode.class.getSimpleName());
|
|
1134 |
SIGS = sigs.toArray(new Class<?>[sigs.size()][]);
|
|
1135 |
}
|
|
1136 |
|
46459
|
1137 |
static boolean containsBinding(InvocationPlugins p, Type declaringType, Binding key) {
|
|
1138 |
String internalName = MetaUtil.toInternalName(declaringType.getTypeName());
|
|
1139 |
ClassPlugins classPlugins = p.registrations.get(internalName);
|
|
1140 |
return classPlugins != null && classPlugins.lookup(key) != null;
|
|
1141 |
}
|
|
1142 |
|
|
1143 |
public static boolean check(InvocationPlugins plugins, Type declaringType, Binding binding) {
|
|
1144 |
InvocationPlugin plugin = binding.plugin;
|
43972
|
1145 |
InvocationPlugins p = plugins.parent;
|
|
1146 |
while (p != null) {
|
46459
|
1147 |
assert !containsBinding(p, declaringType, binding) : "a plugin is already registered for " + binding;
|
43972
|
1148 |
p = p.parent;
|
|
1149 |
}
|
|
1150 |
if (plugin instanceof ForeignCallPlugin || plugin instanceof GeneratedInvocationPlugin) {
|
|
1151 |
return true;
|
|
1152 |
}
|
|
1153 |
if (plugin instanceof MethodSubstitutionPlugin) {
|
|
1154 |
MethodSubstitutionPlugin msplugin = (MethodSubstitutionPlugin) plugin;
|
|
1155 |
Method substitute = msplugin.getJavaSubstitute();
|
|
1156 |
assert substitute.getAnnotation(MethodSubstitution.class) != null : format("Substitute method must be annotated with @%s: %s", MethodSubstitution.class.getSimpleName(), substitute);
|
|
1157 |
return true;
|
|
1158 |
}
|
46459
|
1159 |
int arguments = parseParameters(binding.argumentsDescriptor).size();
|
|
1160 |
assert arguments < SIGS.length : format("need to extend %s to support method with %d arguments: %s", InvocationPlugin.class.getSimpleName(), arguments, binding);
|
43972
|
1161 |
for (Method m : plugin.getClass().getDeclaredMethods()) {
|
|
1162 |
if (m.getName().equals("apply")) {
|
|
1163 |
Class<?>[] parameterTypes = m.getParameterTypes();
|
|
1164 |
if (Arrays.equals(SIGS[arguments], parameterTypes)) {
|
|
1165 |
return true;
|
|
1166 |
}
|
|
1167 |
}
|
|
1168 |
}
|
46459
|
1169 |
throw new AssertionError(format("graph builder plugin for %s not found", binding));
|
|
1170 |
}
|
|
1171 |
|
|
1172 |
static boolean checkResolvable(boolean isOptional, Type declaringType, Binding binding) {
|
48861
|
1173 |
if (declaringType instanceof ResolvedJavaSymbol) {
|
|
1174 |
return checkResolvable(isOptional, ((ResolvedJavaSymbol) declaringType).getResolved(), binding);
|
|
1175 |
}
|
46459
|
1176 |
Class<?> declaringClass = InvocationPlugins.resolveType(declaringType, isOptional);
|
|
1177 |
if (declaringClass == null) {
|
|
1178 |
return true;
|
|
1179 |
}
|
|
1180 |
if (binding.name.equals("<init>")) {
|
|
1181 |
if (resolveConstructor(declaringClass, binding) == null && !isOptional) {
|
|
1182 |
throw new AssertionError(String.format("Constructor not found: %s%s", declaringClass.getName(), binding.argumentsDescriptor));
|
|
1183 |
}
|
|
1184 |
} else {
|
|
1185 |
if (resolveMethod(declaringClass, binding) == null && !isOptional) {
|
|
1186 |
throw new AssertionError(String.format("Method not found: %s.%s%s", declaringClass.getName(), binding.name, binding.argumentsDescriptor));
|
|
1187 |
}
|
|
1188 |
}
|
|
1189 |
return true;
|
43972
|
1190 |
}
|
48861
|
1191 |
|
|
1192 |
private static boolean checkResolvable(boolean isOptional, ResolvedJavaType declaringType, Binding binding) {
|
|
1193 |
if (resolveJavaMethod(declaringType, binding) == null && !isOptional) {
|
|
1194 |
throw new AssertionError(String.format("Method not found: %s.%s%s", declaringType.toJavaName(), binding.name, binding.argumentsDescriptor));
|
|
1195 |
}
|
|
1196 |
return true;
|
|
1197 |
}
|
43972
|
1198 |
}
|
|
1199 |
|
|
1200 |
/**
|
|
1201 |
* Checks a set of nodes added to the graph by an {@link InvocationPlugin}.
|
|
1202 |
*
|
|
1203 |
* @param b the graph builder that applied the plugin
|
|
1204 |
* @param plugin a plugin that was just applied
|
|
1205 |
* @param newNodes the nodes added to the graph by {@code plugin}
|
|
1206 |
* @throws AssertionError if any check fail
|
|
1207 |
*/
|
|
1208 |
public void checkNewNodes(GraphBuilderContext b, InvocationPlugin plugin, NodeIterable<Node> newNodes) {
|
|
1209 |
if (parent != null) {
|
|
1210 |
parent.checkNewNodes(b, plugin, newNodes);
|
|
1211 |
}
|
|
1212 |
}
|
|
1213 |
|
|
1214 |
/**
|
|
1215 |
* Resolves a name to a class.
|
|
1216 |
*
|
|
1217 |
* @param className the name of the class to resolve
|
|
1218 |
* @param optional if true, resolution failure returns null
|
|
1219 |
* @return the resolved class or null if resolution fails and {@code optional} is true
|
|
1220 |
*/
|
|
1221 |
public static Class<?> resolveClass(String className, boolean optional) {
|
|
1222 |
try {
|
|
1223 |
// Need to use the system class loader to handle classes
|
|
1224 |
// loaded by the application class loader which is not
|
|
1225 |
// delegated to by the JVMCI class loader.
|
|
1226 |
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
|
1227 |
return Class.forName(className, false, cl);
|
|
1228 |
} catch (ClassNotFoundException e) {
|
|
1229 |
if (optional) {
|
|
1230 |
return null;
|
|
1231 |
}
|
|
1232 |
throw new GraalError("Could not resolve type " + className);
|
|
1233 |
}
|
|
1234 |
}
|
|
1235 |
|
|
1236 |
/**
|
|
1237 |
* Resolves a {@link Type} to a {@link Class}.
|
|
1238 |
*
|
|
1239 |
* @param type the type to resolve
|
|
1240 |
* @param optional if true, resolution failure returns null
|
|
1241 |
* @return the resolved class or null if resolution fails and {@code optional} is true
|
|
1242 |
*/
|
|
1243 |
public static Class<?> resolveType(Type type, boolean optional) {
|
|
1244 |
if (type instanceof Class) {
|
|
1245 |
return (Class<?>) type;
|
|
1246 |
}
|
46459
|
1247 |
if (type instanceof OptionalLazySymbol) {
|
43972
|
1248 |
return ((OptionalLazySymbol) type).resolve();
|
|
1249 |
}
|
|
1250 |
return resolveClass(type.getTypeName(), optional);
|
|
1251 |
}
|
|
1252 |
|
46459
|
1253 |
private static List<String> toInternalTypeNames(Class<?>[] types) {
|
|
1254 |
String[] res = new String[types.length];
|
|
1255 |
for (int i = 0; i < types.length; i++) {
|
|
1256 |
res[i] = MetaUtil.toInternalName(types[i].getTypeName());
|
|
1257 |
}
|
|
1258 |
return Arrays.asList(res);
|
|
1259 |
}
|
|
1260 |
|
|
1261 |
/**
|
|
1262 |
* Resolves a given binding to a method in a given class. If more than one method with the
|
|
1263 |
* parameter types matching {@code binding} is found and the return types of all the matching
|
|
1264 |
* methods form an inheritance chain, the one with the most specific type is returned; otherwise
|
|
1265 |
* {@link NoSuchMethodError} is thrown.
|
|
1266 |
*
|
|
1267 |
* @param declaringClass the class to search for a method matching {@code binding}
|
48861
|
1268 |
* @return the method (if any) in {@code declaringClass} matching {@code binding}
|
46459
|
1269 |
*/
|
|
1270 |
public static Method resolveMethod(Class<?> declaringClass, Binding binding) {
|
|
1271 |
if (binding.name.equals("<init>")) {
|
|
1272 |
return null;
|
|
1273 |
}
|
|
1274 |
Method[] methods = declaringClass.getDeclaredMethods();
|
|
1275 |
List<String> parameterTypeNames = parseParameters(binding.argumentsDescriptor);
|
48861
|
1276 |
Method match = null;
|
46459
|
1277 |
for (int i = 0; i < methods.length; ++i) {
|
|
1278 |
Method m = methods[i];
|
48861
|
1279 |
if (binding.isStatic == Modifier.isStatic(m.getModifiers()) &&
|
|
1280 |
m.getName().equals(binding.name) &&
|
|
1281 |
parameterTypeNames.equals(toInternalTypeNames(m.getParameterTypes()))) {
|
|
1282 |
if (match == null) {
|
|
1283 |
match = m;
|
|
1284 |
} else if (match.getReturnType().isAssignableFrom(m.getReturnType())) {
|
|
1285 |
// `m` has a more specific return type - choose it
|
|
1286 |
// (`match` is most likely a bridge method)
|
|
1287 |
match = m;
|
|
1288 |
} else {
|
|
1289 |
if (!m.getReturnType().isAssignableFrom(match.getReturnType())) {
|
|
1290 |
throw new NoSuchMethodError(String.format(
|
|
1291 |
"Found 2 methods with same name and parameter types but unrelated return types:%n %s%n %s", match, m));
|
46459
|
1292 |
}
|
48861
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
}
|
|
1296 |
return match;
|
|
1297 |
}
|
|
1298 |
|
|
1299 |
/**
|
|
1300 |
* Same as {@link #resolveMethod(Class, Binding)} and
|
|
1301 |
* {@link #resolveConstructor(Class, Binding)} except in terms of {@link ResolvedJavaType} and
|
|
1302 |
* {@link ResolvedJavaMethod}.
|
|
1303 |
*/
|
|
1304 |
public static ResolvedJavaMethod resolveJavaMethod(ResolvedJavaType declaringClass, Binding binding) {
|
|
1305 |
ResolvedJavaMethod[] methods = declaringClass.getDeclaredMethods();
|
|
1306 |
if (binding.name.equals("<init>")) {
|
|
1307 |
for (ResolvedJavaMethod m : methods) {
|
|
1308 |
if (m.getName().equals("<init>") && m.getSignature().toMethodDescriptor().startsWith(binding.argumentsDescriptor)) {
|
46459
|
1309 |
return m;
|
|
1310 |
}
|
|
1311 |
}
|
48861
|
1312 |
return null;
|
46459
|
1313 |
}
|
48861
|
1314 |
|
|
1315 |
ResolvedJavaMethod match = null;
|
|
1316 |
for (int i = 0; i < methods.length; ++i) {
|
|
1317 |
ResolvedJavaMethod m = methods[i];
|
|
1318 |
if (binding.isStatic == m.isStatic() &&
|
|
1319 |
m.getName().equals(binding.name) &&
|
|
1320 |
m.getSignature().toMethodDescriptor().startsWith(binding.argumentsDescriptor)) {
|
|
1321 |
if (match == null) {
|
|
1322 |
match = m;
|
|
1323 |
} else {
|
|
1324 |
final ResolvedJavaType matchReturnType = (ResolvedJavaType) match.getSignature().getReturnType(declaringClass);
|
|
1325 |
final ResolvedJavaType mReturnType = (ResolvedJavaType) m.getSignature().getReturnType(declaringClass);
|
|
1326 |
if (matchReturnType.isAssignableFrom(mReturnType)) {
|
|
1327 |
// `m` has a more specific return type - choose it
|
|
1328 |
// (`match` is most likely a bridge method)
|
|
1329 |
match = m;
|
|
1330 |
} else {
|
|
1331 |
if (!mReturnType.isAssignableFrom(matchReturnType)) {
|
|
1332 |
throw new NoSuchMethodError(String.format(
|
|
1333 |
"Found 2 methods with same name and parameter types but unrelated return types:%n %s%n %s", match, m));
|
|
1334 |
}
|
|
1335 |
}
|
|
1336 |
}
|
|
1337 |
}
|
|
1338 |
}
|
|
1339 |
return match;
|
46459
|
1340 |
}
|
43972
|
1341 |
|
|
1342 |
/**
|
46459
|
1343 |
* Resolves a given binding to a constructor in a given class.
|
43972
|
1344 |
*
|
46459
|
1345 |
* @param declaringClass the class to search for a constructor matching {@code binding}
|
|
1346 |
* @return the constructor (if any) in {@code declaringClass} matching binding
|
43972
|
1347 |
*/
|
46459
|
1348 |
public static Constructor<?> resolveConstructor(Class<?> declaringClass, Binding binding) {
|
|
1349 |
if (!binding.name.equals("<init>")) {
|
|
1350 |
return null;
|
|
1351 |
}
|
|
1352 |
Constructor<?>[] constructors = declaringClass.getDeclaredConstructors();
|
|
1353 |
List<String> parameterTypeNames = parseParameters(binding.argumentsDescriptor);
|
|
1354 |
for (int i = 0; i < constructors.length; ++i) {
|
|
1355 |
Constructor<?> c = constructors[i];
|
|
1356 |
if (parameterTypeNames.equals(toInternalTypeNames(c.getParameterTypes()))) {
|
|
1357 |
return c;
|
|
1358 |
}
|
43972
|
1359 |
}
|
46459
|
1360 |
return null;
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
private static List<String> parseParameters(String argumentsDescriptor) {
|
|
1364 |
assert argumentsDescriptor.startsWith("(") && argumentsDescriptor.endsWith(")") : argumentsDescriptor;
|
|
1365 |
List<String> res = new ArrayList<>();
|
|
1366 |
int cur = 1;
|
|
1367 |
int end = argumentsDescriptor.length() - 1;
|
|
1368 |
while (cur != end) {
|
|
1369 |
char first;
|
|
1370 |
int start = cur;
|
|
1371 |
do {
|
|
1372 |
first = argumentsDescriptor.charAt(cur++);
|
|
1373 |
} while (first == '[');
|
|
1374 |
|
|
1375 |
switch (first) {
|
|
1376 |
case 'L':
|
|
1377 |
int endObject = argumentsDescriptor.indexOf(';', cur);
|
|
1378 |
if (endObject == -1) {
|
|
1379 |
throw new GraalError("Invalid object type at index %d in signature: %s", cur, argumentsDescriptor);
|
|
1380 |
}
|
|
1381 |
cur = endObject + 1;
|
|
1382 |
break;
|
|
1383 |
case 'V':
|
|
1384 |
case 'I':
|
|
1385 |
case 'B':
|
|
1386 |
case 'C':
|
|
1387 |
case 'D':
|
|
1388 |
case 'F':
|
|
1389 |
case 'J':
|
|
1390 |
case 'S':
|
|
1391 |
case 'Z':
|
|
1392 |
break;
|
|
1393 |
default:
|
|
1394 |
throw new GraalError("Invalid character at index %d in signature: %s", cur, argumentsDescriptor);
|
|
1395 |
}
|
|
1396 |
res.add(argumentsDescriptor.substring(start, cur));
|
43972
|
1397 |
}
|
46459
|
1398 |
return res;
|
43972
|
1399 |
}
|
|
1400 |
}
|