Top Inners Fields Constructors Methods
org.codehaus.groovy.vmplugin.v8

public abstract Class Selector

extends Object
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector
Imports
groovy.lang.AdaptingMetaClass, .Closure, .ExpandoMetaClass, .GroovyInterceptable, .GroovyObject, .GroovyRuntimeException, .GroovySystem, .MetaClass, .MetaClassImpl, .MetaClassImpl.MetaConstructor, .MetaMethod, .MetaProperty, .MissingMethodException, groovy.transform.Internal, org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.reflection.CachedField, .CachedMethod, .ClassInfo, .GeneratedMetaMethod, org.codehaus.groovy.reflection.stdclasses.CachedSAMClass, org.codehaus.groovy.runtime.GeneratedClosure, .GroovyCategorySupport, .GroovyCategorySupport.CategoryMethod, .NullObject, org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod, org.codehaus.groovy.runtime.metaclass.ClosureMetaClass, .MetaClassRegistryImpl, .MethodMetaProperty, .NewInstanceMetaMethod, .NewStaticMetaMethod, .ReflectionMetaMethod, org.codehaus.groovy.runtime.wrappers.Wrapper, org.codehaus.groovy.vmplugin.VMPlugin, .VMPluginFactory, org.codehaus.groovy.vmplugin.v8.IndyInterface.CallType, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, .MutableCallSite, java.lang.reflect.Array, .Constructor, .Field, .Method, .Modifier, java.util.ArrayList, .Collection, .HashSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
Selector.MethodSelector

Method invocation based Selector.

private static class

Field Summary

Modifier and TypeField and Description
public Object[]
public boolean
private static final IndyInterface.CallType[]
CALL_TYPE_VALUES

Cache values for read-only access

public MutableCallSite
public IndyInterface.CallType
public boolean
public MethodType
public MethodHandle
public boolean
public MetaMethod
public String
public Object[]
public boolean
public boolean
public Class<?>
public Class<?>
public boolean
public boolean
public MethodType
public boolean
public boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
getCorrectedReceiver()

Returns NullObject#getNullObject() if the receiver (args[0]) is null.

private static MetaClassImpl
getMetaClassImpl(MetaClass mc, boolean includeEMC)

Returns the MetaClassImpl if the given MetaClass is one of MetaClassImpl, AdaptingMetaClass or ClosureMetaClass.

public static Selector
getSelector(MutableCallSite callSite, Class<?> sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Returns the Selector

private static Object[]
removeRealReceiver(Object[] args)

Helper method to remove the receiver from the argument array by producing a new array.

pack-priv abstract void
private static Object[]
spread(Object[] args, boolean spreadCall)

Helper method to transform the given arguments, consisting of the receiver and the actual arguments in an Object[], into a new Object[] consisting of the receiver and the arguments directly.

private static Object
unwrapIfWrapped(Object object)

Unwraps the given object from a Wrapper.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argsback to summary
public Object[] args
cacheback to summary
public boolean cache
CALL_TYPE_VALUESback to summary
private static final IndyInterface.CallType[] CALL_TYPE_VALUES

Cache values for read-only access

callSiteback to summary
public MutableCallSite callSite
callTypeback to summary
public IndyInterface.CallType callType
catchExceptionback to summary
public boolean catchException
currentTypeback to summary
public MethodType currentType
handleback to summary
public MethodHandle handle
isVargsback to summary
public boolean isVargs
methodback to summary
public MetaMethod method
nameback to summary
public String name
originalArgumentsback to summary
public Object[] originalArguments
safeNavigationback to summary
public boolean safeNavigation
safeNavigationOrigback to summary
public boolean safeNavigationOrig
selectionBaseback to summary
public Class<?> selectionBase
senderback to summary
public Class<?> sender
skipSpreadCollectorback to summary
public boolean skipSpreadCollector
spreadback to summary
public boolean spread
targetTypeback to summary
public MethodType targetType
thisCallback to summary
public boolean thisCall
useMetaClassback to summary
public boolean useMetaClass

Constructor Detail

Selectorback to summary
public Selector()

Method Detail

getCorrectedReceiverback to summary
public Object getCorrectedReceiver()

Returns NullObject#getNullObject() if the receiver (args[0]) is null. If it is not null, the receiver itself is returned.

getMetaClassImplback to summary
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC)

Returns the MetaClassImpl if the given MetaClass is one of MetaClassImpl, AdaptingMetaClass or ClosureMetaClass. If none of these cases matches, this method returns null.

getSelectorback to summary
public static Selector getSelector(MutableCallSite callSite, Class<?> sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Returns the Selector

removeRealReceiverback to summary
private static Object[] removeRealReceiver(Object[] args)

Helper method to remove the receiver from the argument array by producing a new array.

setCallSiteTargetback to summary
pack-priv abstract void setCallSiteTarget()
spreadback to summary
private static Object[] spread(Object[] args, boolean spreadCall)

Helper method to transform the given arguments, consisting of the receiver and the actual arguments in an Object[], into a new Object[] consisting of the receiver and the arguments directly. Before the size of args was always 2, the returned Object[] will have a size of 1+n, where n is the number arguments.

unwrapIfWrappedback to summary
private static Object unwrapIfWrapped(Object object)

Unwraps the given object from a Wrapper. If not wrapped, the given object is returned.

org.codehaus.groovy.vmplugin.v8 back to summary

private Class Selector.CastSelector

extends MethodSelector
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final Class<?>
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
mc

Constructor Summary

AccessConstructor and Description
public
CastSelector(MutableCallSite callSite, Object[] arguments)

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
private void
private void
private void
private void
private static boolean
isAbstractClassOf(Class<?> toTest, Class<?> givenOnCallSite)

public void
setCallSiteTarget()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setCallSiteTarget.

setting a call site target consists of the following steps: # get the meta class # select a method/constructor/property from it, if it is a MetaClassImpl # make a handle out of the selection # if nothing could be selected, select a path through the given MetaClass or the GroovyObject # apply transformations for vargs, implicit null argument, coercion, wrapping, null receiver and spreading
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
addExceptionHandlerchooseMetacorrectCoercecorrectNullReceivercorrectParameterLengthcorrectSpreadingcorrectWrappingdoCallSiteTargetSetgetMetaClasssetGuardssetHandleForMetaMethodsetInterceptorsetMetaClassCallHandleIfNeededsetNullForSafeNavigationsetSelectionBase

Field Detail

staticSourceTypeback to summary
private final Class<?> staticSourceType
staticTargetTypeback to summary
private final Class<?> staticTargetType

Constructor Detail

CastSelectorback to summary
public CastSelector(MutableCallSite callSite, Object[] arguments)

Method Detail

castAndSetGuardsback to summary
private void castAndSetGuards()
castToTypeFallBackback to summary
private void castToTypeFallBack()
handleBooleanback to summary
private void handleBoolean()
handleCollectionsback to summary
private void handleCollections()
handleInstanceCaseback to summary
private void handleInstanceCase()
handleNullWithoutBooleanback to summary
private void handleNullWithoutBoolean()
handleSAMback to summary
private void handleSAM()
isAbstractClassOfback to summary
private static boolean isAbstractClassOf(Class<?> toTest, Class<?> givenOnCallSite)
setCallSiteTargetback to summary
public void setCallSiteTarget()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setCallSiteTarget.

Doc from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setCallSiteTarget.

setting a call site target consists of the following steps: # get the meta class # select a method/constructor/property from it, if it is a MetaClassImpl # make a handle out of the selection # if nothing could be selected, select a path through the given MetaClass or the GroovyObject # apply transformations for vargs, implicit null argument, coercion, wrapping, null receiver and spreading

Annotations
@Override
org.codehaus.groovy.vmplugin.v8 back to summary

private Class Selector.InitSelector

extends MethodSelector
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
mc

Constructor Summary

AccessConstructor and Description
public
InitSelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Method Summary

Modifier and TypeMethod and Description
public void
chooseMeta(MetaClassImpl mci)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.chooseMeta.

This method chooses a constructor from the meta class.
public void
correctCoerce()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.correctCoerce.

In case of a bean constructor we don't do any coercion, otherwise we do the same as for MethodSelector#correctCoerce()
public void
correctParameterLength()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.correctParameterLength.

In case of a bean constructor we don't do any varags or implicit null argument transformations.
public MetaClass
getMetaClass()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.getMetaClass.

For a constructor call we always use the static meta class from the registry
public void
public boolean
setInterceptor()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setInterceptor.

Constructor calls are not intercepted, thus always returns false.
public void
setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setMetaClassCallHandleIfNeeded.

Set MOP based constructor invocation path.
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
addExceptionHandlercorrectNullReceivercorrectSpreadingcorrectWrappingdoCallSiteTargetSetsetCallSiteTargetsetGuardssetNullForSafeNavigationsetSelectionBase

Field Detail

beanConstructorback to summary
private boolean beanConstructor

Constructor Detail

InitSelectorback to summary
public InitSelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Method Detail

chooseMetaback to summary
public void chooseMeta(MetaClassImpl mci)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.chooseMeta.

This method chooses a constructor from the meta class.

Annotations
@Override
correctCoerceback to summary
public void correctCoerce()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.correctCoerce.

In case of a bean constructor we don't do any coercion, otherwise we do the same as for MethodSelector#correctCoerce()

Annotations
@Override
correctParameterLengthback to summary
public void correctParameterLength()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.correctParameterLength.

In case of a bean constructor we don't do any varags or implicit null argument transformations. Otherwise we do the same as for MethodSelector#correctParameterLength()

Annotations
@Override
getMetaClassback to summary
public MetaClass getMetaClass()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.getMetaClass.

For a constructor call we always use the static meta class from the registry

Annotations
@Override
setHandleForMetaMethodback to summary
public void setHandleForMetaMethod()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setHandleForMetaMethod.

Adds MetaConstructor handling.

Annotations
@Override
setInterceptorback to summary
public boolean setInterceptor()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setInterceptor.

Constructor calls are not intercepted, thus always returns false.

Annotations
@Override
setMetaClassCallHandleIfNeededback to summary
public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setMetaClassCallHandleIfNeeded.

Set MOP based constructor invocation path.

Annotations
@Override
org.codehaus.groovy.vmplugin.v8 back to summary

private Class Selector.MethodSelector

extends Selector
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.vmplugin.v8.Selector.CastSelector, org.codehaus.groovy.vmplugin.v8.Selector.PropertySelector, org.codehaus.groovy.vmplugin.v8.Selector.InitSelector

Method invocation based Selector. This Selector is called for method invocations and is base for constructor calls as well as getProperty calls.

Field Summary

Modifier and TypeField and Description
private boolean
protected MetaClass
private static final Object[]
Inherited from org.codehaus.groovy.vmplugin.v8.Selector:
argscachecallSitecallTypecatchExceptioncurrentTypehandleisVargsmethodnameoriginalArgumentssafeNavigationsafeNavigationOrigselectionBasesenderskipSpreadCollectorspreadtargetTypethisCalluseMetaClass

Constructor Summary

AccessConstructor and Description
public
MethodSelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[] arguments)

Method Summary

Modifier and TypeMethod and Description
public void
addExceptionHandler()

Adds the standard exception handler.

public void
chooseMeta(MetaClassImpl mci)

Uses the meta class to get a meta method for a method call.

public void
correctCoerce()

There are some conversions we have to do explicitly.

public void
correctNullReceiver()

Gives a replacement receiver for null.

public void
correctParameterLength()

Handles cases in which we have to correct the length of arguments using the parameters.

public void
public void
correctWrapping()

Corrects method argument wrapping.

public void
doCallSiteTargetSet()

do the actual call site target set, if the call is supposed to be cached

public MetaClass
getMetaClass()

Gives the meta class to an Object.

private MethodType
removeWrapper(MethodType targetType)

Helper method to manipulate the given type to replace Wrapper with Object.

public void
setCallSiteTarget()

Implements abstract org.codehaus.groovy.vmplugin.v8.Selector.setCallSiteTarget.

setting a call site target consists of the following steps: # get the meta class # select a method/constructor/property from it, if it is a MetaClassImpl # make a handle out of the selection # if nothing could be selected, select a path through the given MetaClass or the GroovyObject # apply transformations for vargs, implicit null argument, coercion, wrapping, null receiver and spreading
public void
setGuards(Object receiver)

Sets all argument and receiver guards.

public void
setHandleForMetaMethod()

Creates a MethodHandle using a before selected MetaMethod.

public boolean
public void
setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Creates a MethodHandle, which will use the meta class path.

public boolean
setNullForSafeNavigation()

Sets the null constant for safe navigation.

public void
setSelectionBase()

Sets the selection base.

Inherited from org.codehaus.groovy.vmplugin.v8.Selector:
getCorrectedReceivergetSelector

Field Detail

isCategoryMethodback to summary
private boolean isCategoryMethod
mcback to summary
protected MetaClass mc
SINGLE_NULL_ARRAYback to summary
private static final Object[] SINGLE_NULL_ARRAY

Constructor Detail

MethodSelectorback to summary
public MethodSelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[] arguments)

Method Detail

addExceptionHandlerback to summary
public void addExceptionHandler()

Adds the standard exception handler.

chooseMetaback to summary
public void chooseMeta(MetaClassImpl mci)

Uses the meta class to get a meta method for a method call. There will be no meta method selected, if the meta class is no MetaClassImpl or the meta class is an AdaptingMetaClass.

correctCoerceback to summary
public void correctCoerce()

There are some conversions we have to do explicitly. These are GString to String, Number to Byte and Number to BigInteger conversions.

correctNullReceiverback to summary
public void correctNullReceiver()

Gives a replacement receiver for null. In case of the receiver being null we want to do the method invocation on NullObject instead.

correctParameterLengthback to summary
public void correctParameterLength()

Handles cases in which we have to correct the length of arguments using the parameters. This might be needed for vargs and for one parameter calls without arguments (null is used then).

correctSpreadingback to summary
public void correctSpreading()
correctWrappingback to summary
public void correctWrapping()

Corrects method argument wrapping. In cases in which we want to force a certain method selection we use Wrapper classes to transport the static type information. This method will be used to undo the wrapping.

doCallSiteTargetSetback to summary
public void doCallSiteTargetSet()

do the actual call site target set, if the call is supposed to be cached

getMetaClassback to summary
public MetaClass getMetaClass()

Gives the meta class to an Object.

removeWrapperback to summary
private MethodType removeWrapper(MethodType targetType)

Helper method to manipulate the given type to replace Wrapper with Object.

setCallSiteTargetback to summary
public void setCallSiteTarget()

Implements abstract org.codehaus.groovy.vmplugin.v8.Selector.setCallSiteTarget.

setting a call site target consists of the following steps: # get the meta class # select a method/constructor/property from it, if it is a MetaClassImpl # make a handle out of the selection # if nothing could be selected, select a path through the given MetaClass or the GroovyObject # apply transformations for vargs, implicit null argument, coercion, wrapping, null receiver and spreading

Annotations
@Override
setGuardsback to summary
public void setGuards(Object receiver)

Sets all argument and receiver guards.

setHandleForMetaMethodback to summary
public void setHandleForMetaMethod()

Creates a MethodHandle using a before selected MetaMethod. If the MetaMethod has reflective information available, then we will use that information to create the target MethodHandle. If that is not the case we will produce a handle, which will use the MetaMethod itself for invocation.

setInterceptorback to summary
public boolean setInterceptor()

Sets a handle to call GroovyInterceptable#invokeMethod(String, Object)

setMetaClassCallHandleIfNeededback to summary
public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Creates a MethodHandle, which will use the meta class path. This method is called only if no handle has been created before. This is usually the case if the method selection failed.

setNullForSafeNavigationback to summary
public boolean setNullForSafeNavigation()

Sets the null constant for safe navigation. In case of foo?.bar() and foo being null, we don't call the method, instead we simply return null. This produces a handle, which will return the constant.

setSelectionBaseback to summary
public void setSelectionBase()

Sets the selection base.

org.codehaus.groovy.vmplugin.v8 back to summary

private Class Selector.PropertySelector

extends MethodSelector
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
mc

Constructor Summary

AccessConstructor and Description
public
PropertySelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Method Summary

Modifier and TypeMethod and Description
public void
chooseMeta(MetaClassImpl mci)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.chooseMeta.

this method chooses a property from the meta class.
private boolean
isMarkedInternal(Method reflectionMethod)

public void
setHandleForMetaMethod()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setHandleForMetaMethod.

Additionally to the normal MethodSelector#setHandleForMetaMethod() task we have to also take care of generic getter methods, that depends on the name.
public boolean
setInterceptor()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setInterceptor.

We never got the interceptor path with a property get
public void
setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setMetaClassCallHandleIfNeeded.

The MOP requires all get property operations to go through GroovyObject#getProperty(String).
Inherited from org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector:
addExceptionHandlercorrectCoercecorrectNullReceivercorrectParameterLengthcorrectSpreadingcorrectWrappingdoCallSiteTargetSetgetMetaClasssetCallSiteTargetsetGuardssetNullForSafeNavigationsetSelectionBase

Field Detail

insertNameback to summary
private boolean insertName

Constructor Detail

PropertySelectorback to summary
public PropertySelector(MutableCallSite callSite, Class<?> sender, String methodName, IndyInterface.CallType callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)

Method Detail

chooseMetaback to summary
public void chooseMeta(MetaClassImpl mci)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.chooseMeta.

this method chooses a property from the meta class.

Annotations
@Override
isMarkedInternalback to summary
private boolean isMarkedInternal(Method reflectionMethod)
setHandleForMetaMethodback to summary
public void setHandleForMetaMethod()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setHandleForMetaMethod.

Additionally to the normal MethodSelector#setHandleForMetaMethod() task we have to also take care of generic getter methods, that depends on the name.

Annotations
@Override
setInterceptorback to summary
public boolean setInterceptor()

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setInterceptor.

We never got the interceptor path with a property get

Annotations
@Override
setMetaClassCallHandleIfNeededback to summary
public void setMetaClassCallHandleIfNeeded(boolean standardMetaClass)

Overrides org.codehaus.groovy.vmplugin.v8.Selector.MethodSelector.setMetaClassCallHandleIfNeeded.

The MOP requires all get property operations to go through GroovyObject#getProperty(String). We do this in case no property was found before.

Annotations
@Override