public final class MethodSubstitutionPlugin extends Object implements InvocationPlugin
InvocationPlugin for a method where the implementation of the method is provided by a
substitute method. A substitute method must be
static even if the substituted method is not.InvocationPlugin.Receiver| Modifier and Type | Field and Description |
|---|---|
private ResolvedJavaMethod |
cachedSubstitute |
private Class<?> |
declaringClass
The class in which the substitute method is declared.
|
private String |
name
The name of the original and substitute method.
|
private boolean |
originalIsStatic |
private Class<?>[] |
parameters
The parameter types of the substitute method.
|
| Constructor and Description |
|---|
MethodSubstitutionPlugin(boolean originalIsStatic,
Class<?> declaringClass,
String name,
Class<?>... parameters)
Creates a method substitution plugin.
|
MethodSubstitutionPlugin(Class<?> declaringClass,
String name,
Class<?>... parameters)
Creates a method substitution plugin.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
execute(GraphBuilderContext b,
ResolvedJavaMethod targetMethod,
InvocationPlugin.Receiver receiver,
ValueNode[] argsIncludingReceiver)
Executes this plugin against a set of invocation arguments.
|
StackTraceElement |
getApplySourceLocation(MetaAccessProvider metaAccess) |
(package private) Method |
getJavaSubstitute()
Gets the reflection API version of the substitution method.
|
ResolvedJavaMethod |
getSubstitute(MetaAccessProvider metaAccess)
Gets the substitute method, resolving it first if necessary.
|
boolean |
inlineOnly()
Determines if this plugin can only be used when inlining the method is it associated with.
|
private boolean |
isSubstitute(Method m)
Determines if a given method is the substitute method of this plugin.
|
private Method |
lookupSubstitute()
Gets the substitute method of this plugin.
|
static Class<?> |
resolveClass(String className,
boolean optional)
Resolves a name to a class.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapply, apply, apply, apply, apply, apply, applyPolymorphic, defaultHandler, isSignaturePolymorphicprivate ResolvedJavaMethod cachedSubstitute
private final Class<?> declaringClass
private final Class<?>[] parameters
private final boolean originalIsStatic
public MethodSubstitutionPlugin(Class<?> declaringClass, String name, Class<?>... parameters)
declaringClass - the class in which the substitute method is declaredname - the name of the substitute methodparameters - the parameter types of the substitute method. If the original method is not
static, then parameters[0] must be the Class value denoting
InvocationPlugin.Receiverpublic MethodSubstitutionPlugin(boolean originalIsStatic, Class<?> declaringClass, String name, Class<?>... parameters)
declaringClass - the class in which the substitute method is declaredname - the name of the substitute methodparameters - the parameter types of the substitute methodpublic boolean inlineOnly()
InvocationPlugininlineOnly in interface InvocationPluginpublic ResolvedJavaMethod getSubstitute(MetaAccessProvider metaAccess)
Method getJavaSubstitute() throws JVMCIError
JVMCIErrorprivate boolean isSubstitute(Method m)
private Method lookupSubstitute()
public static Class<?> resolveClass(String className, boolean optional)
className - the name of the class to resolveoptional - if true, resolution failure returns nulloptional is truepublic boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] argsIncludingReceiver)
InvocationPluginInvocationPlugin dispatches to the apply(...)
method that matches the number of arguments or to InvocationPlugin.applyPolymorphic(com.oracle.graal.graphbuilderconf.GraphBuilderContext, jdk.internal.jvmci.meta.ResolvedJavaMethod, com.oracle.graal.graphbuilderconf.InvocationPlugin.Receiver, com.oracle.graal.nodes.ValueNode...) if plugin
is signature polymorphic.execute in interface InvocationPlugintargetMethod - the method for which this plugin is being appliedreceiver - access to the receiver, null if targetMethod is staticargsIncludingReceiver - all arguments to the invocation include the receiver in position
0 if targetMethod is not statictrue if this plugin handled the invocation of targetMethod
false if the graph builder should process the invoke further (e.g., by
inlining it or creating an Invoke node). A plugin that does not handle an
invocation must not modify the graph being constructed.public StackTraceElement getApplySourceLocation(MetaAccessProvider metaAccess)
getApplySourceLocation in interface InvocationPlugin