Class AbstractCallSite
java.lang.Object
org.codehaus.groovy.runtime.callsite.AbstractCallSite
- All Implemented Interfaces:
CallSite
- Direct Known Subclasses:
GetEffectivePogoFieldSite,GetEffectivePojoPropertySite,MetaClassSite,NullCallSite,PerInstancePojoMetaClassSite,PogoGetPropertySite,PogoInterceptableSite,PogoMetaClassGetPropertySite,PojoMetaClassGetPropertySite
Base class for all classic (non-
invokedynamic) call sites.
Prefer invokedynamic call sites for new code. Planned for deprecation/removal in a future Groovy version.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CallSiteArrayCallSiteArraythat owns this site and stores it atindex.protected final intPosition of this site inarray.protected final StringName of the call or property this site resolves. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCallSite(CallSite prev) Creates a site that copies the name, index, and owning array fromprev.AbstractCallSite(CallSiteArray array, int index, String name) Creates a site fornameatindexinarray. -
Method Summary
Modifier and TypeMethodDescriptionacceptGetProperty(Object receiver) Returns the property-read sitecreateGetPropertySite(Object)selects forreceiver.acceptGroovyObjectGetProperty(Object receiver) Returns the property-read sitecreateGroovyObjectGetPropertySite(Object)selects forreceiver.Forwards tocall(Object, Object[])with an empty argument array (CallSiteArray.NOPARAM).Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.call(Object, Object)on that site.Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.call(Object, Object, Object)on that site.Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.call(Object, Object, Object, Object)on that site.Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.call(Object, Object, Object, Object, Object)on that site.callConstructor(Object receiver) Forwards tocallConstructor(Object, Object[])with an empty argument array (CallSiteArray.NOPARAM).callConstructor(Object receiver, Object arg1) Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callConstructor(Object, Object)on that site.callConstructor(Object receiver, Object[] args) Forwards this site, the class to construct (receiver), andargstoCallSiteArray.defaultCallConstructor(CallSite, Object, Object[]).callConstructor(Object receiver, Object arg1, Object arg2) Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callConstructor(Object, Object, Object)on that site.callConstructor(Object receiver, Object arg1, Object arg2, Object arg3) Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callConstructor(Object, Object, Object, Object)on that site.Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callConstructor(Object, Object, Object, Object, Object)on that site.callCurrent(GroovyObject receiver) Forwards tocallCurrent(GroovyObject, Object[])with an empty argument array (CallSiteArray.NOPARAM).callCurrent(GroovyObject receiver, Object arg1) Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callCurrent(GroovyObject, Object)on that site.callCurrent(GroovyObject receiver, Object[] args) Forwards this site, theGroovyObjectreceiver, andargstoCallSiteArray.defaultCallCurrent(CallSite, GroovyObject, Object[]).callCurrent(GroovyObject receiver, Object arg1, Object arg2) Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callCurrent(GroovyObject, Object, Object)on that site.callCurrent(GroovyObject receiver, Object arg1, Object arg2, Object arg3) Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callCurrent(GroovyObject, Object, Object, Object)on that site.callCurrent(GroovyObject receiver, Object arg1, Object arg2, Object arg3, Object arg4) Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callCurrent(GroovyObject, Object, Object, Object, Object)on that site.callGetProperty(Object receiver) Reads the property named bygetName()fromreceiverthrough the siteacceptGetProperty(Object)returns.final ObjectcallGetPropertySafe(Object receiver) callGroovyObjectGetProperty(Object receiver) Reads the property named bygetName().final ObjectcallGroovyObjectGetPropertySafe(Object receiver) final Objectfinal Objectfinal Objectfinal ObjectReturnsnullwhenreceiverisnull; otherwise forwardsarg1andarg2tocall(Object, Object, Object).final ObjectReturnsnullwhenreceiverisnull; otherwise forwardsarg1,arg2, andarg3tocall(Object, Object, Object, Object).Returnsnullwhenreceiverisnull; otherwise forwardsarg1througharg4tocall(Object, Object, Object, Object, Object).callStatic(Class receiver) Forwards tocallStatic(Class, Object[])with an empty argument array (CallSiteArray.NOPARAM).callStatic(Class receiver, Object arg1) Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callStatic(Class, Object)on that site.callStatic(Class receiver, Object[] args) Forwards this site, theClassreceiver, andargstoCallSiteArray.defaultCallStatic(CallSite, Class, Object[]).callStatic(Class receiver, Object arg1, Object arg2) Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callStatic(Class, Object, Object)on that site.callStatic(Class receiver, Object arg1, Object arg2, Object arg3) Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callStatic(Class, Object, Object, Object)on that site.Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callStatic(Class, Object, Object, Object, Object)on that site.protected final CallSitecreateGetPropertySite(Object receiver) Selects a property-read site forreceiver.protected final CallSitecreateGroovyObjectGetPropertySite(Object receiver) Selects a property-read site forreceiver.getArray()Returns theCallSiteArraythat owns this site.intgetIndex()Returns this site's position ingetArray().getName()Returns the call or property name this site resolves.getProperty(Object receiver) ThrowsUnsupportedOperationException.
-
Field Details
-
index
protected final int indexPosition of this site inarray. -
name
Name of the call or property this site resolves. -
array
CallSiteArraythat owns this site and stores it atindex.
-
-
Constructor Details
-
AbstractCallSite
Creates a site fornameatindexinarray. -
AbstractCallSite
Creates a site that copies the name, index, and owning array fromprev.
-
-
Method Details
-
getIndex
public int getIndex()Returns this site's position ingetArray(). -
getArray
Returns theCallSiteArraythat owns this site. -
getName
Returns the call or property name this site resolves. -
callSafe
-
callSafe
-
callSafe
-
callSafe
Returnsnullwhenreceiverisnull; otherwise forwardsarg1andarg2tocall(Object, Object, Object). -
callSafe
public final Object callSafe(Object receiver, Object arg1, Object arg2, Object arg3) throws Throwable Returnsnullwhenreceiverisnull; otherwise forwardsarg1,arg2, andarg3tocall(Object, Object, Object, Object). -
callSafe
public Object callSafe(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable Returnsnullwhenreceiverisnull; otherwise forwardsarg1througharg4tocall(Object, Object, Object, Object, Object).- Specified by:
callSafein interfaceCallSite- Parameters:
receiver- the target of the call; may be nullarg1- the first argumentarg2- the second argumentarg3- the third argumentarg4- the fourth argument- Returns:
- the value returned by the method, or null when
receiveris null - Throws:
Throwable- when the call fails
-
call
-
call
Forwards tocall(Object, Object[])with an empty argument array (CallSiteArray.NOPARAM). -
call
Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.call(Object, Object)on that site. Otherwise packsarg1into an array and forwards tocall(Object, Object[]). -
call
Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.call(Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocall(Object, Object[]). -
call
Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.call(Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocall(Object, Object[]). -
call
public Object call(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.call(Object, Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocall(Object, Object[]). -
callCurrent
Forwards this site, theGroovyObjectreceiver, andargstoCallSiteArray.defaultCallCurrent(CallSite, GroovyObject, Object[]).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy objectargs- the arguments, in order- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callCurrent
Forwards tocallCurrent(GroovyObject, Object[])with an empty argument array (CallSiteArray.NOPARAM).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy object- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callCurrent
Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callCurrent(GroovyObject, Object)on that site. Otherwise packsarg1into an array and forwards tocallCurrent(GroovyObject, Object[]).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy objectarg1- the only argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callCurrent
Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callCurrent(GroovyObject, Object, Object)on that site. Otherwise packs those arguments and forwards tocallCurrent(GroovyObject, Object[]).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy objectarg1- the first argumentarg2- the second argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callCurrent
public Object callCurrent(GroovyObject receiver, Object arg1, Object arg2, Object arg3) throws Throwable Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callCurrent(GroovyObject, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallCurrent(GroovyObject, Object[]).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy objectarg1- the first argumentarg2- the second argumentarg3- the third argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callCurrent
public Object callCurrent(GroovyObject receiver, Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callCurrent(GroovyObject, Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallCurrent(GroovyObject, Object[]).- Specified by:
callCurrentin interfaceCallSite- Parameters:
receiver- the current Groovy objectarg1- the first argumentarg2- the second argumentarg3- the third argumentarg4- the fourth argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
Forwards this site, theClassreceiver, andargstoCallSiteArray.defaultCallStatic(CallSite, Class, Object[]).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the methodargs- the arguments, in order- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
Forwards tocallStatic(Class, Object[])with an empty argument array (CallSiteArray.NOPARAM).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the method- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callStatic(Class, Object)on that site. Otherwise packsarg1into an array and forwards tocallStatic(Class, Object[]).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the methodarg1- the only argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callStatic(Class, Object, Object)on that site. Otherwise packs those arguments and forwards tocallStatic(Class, Object[]).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the methodarg1- the first argumentarg2- the second argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callStatic(Class, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallStatic(Class, Object[]).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the methodarg1- the first argumentarg2- the second argumentarg3- the third argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callStatic
public Object callStatic(Class receiver, Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callStatic(Class, Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallStatic(Class, Object[]).- Specified by:
callStaticin interfaceCallSite- Parameters:
receiver- the class that declares the methodarg1- the first argumentarg2- the second argumentarg3- the third argumentarg4- the fourth argument- Returns:
- the value returned by the method
- Throws:
Throwable- when the call fails
-
callConstructor
Forwards this site, the class to construct (receiver), andargstoCallSiteArray.defaultCallConstructor(CallSite, Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the callerargs- the constructor arguments, in order- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callConstructor
Forwards tocallConstructor(Object, Object[])with an empty argument array (CallSiteArray.NOPARAM).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the caller- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callConstructor
Whenarrayholds a different site atindex, forwardsreceiverandarg1toCallSite.callConstructor(Object, Object)on that site. Otherwise packsarg1into an array and forwards tocallConstructor(Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the callerarg1- the only constructor argument- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callConstructor
Whenarrayholds a different site atindex, forwardsreceiver,arg1, andarg2toCallSite.callConstructor(Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallConstructor(Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the callerarg1- the first constructor argumentarg2- the second constructor argument- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callConstructor
public Object callConstructor(Object receiver, Object arg1, Object arg2, Object arg3) throws Throwable Whenarrayholds a different site atindex, forwardsreceiver,arg1,arg2, andarg3toCallSite.callConstructor(Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallConstructor(Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the callerarg1- the first constructor argumentarg2- the second constructor argumentarg3- the third constructor argument- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callConstructor
public Object callConstructor(Object receiver, Object arg1, Object arg2, Object arg3, Object arg4) throws Throwable Whenarrayholds a different site atindex, forwardsreceiverandarg1througharg4toCallSite.callConstructor(Object, Object, Object, Object, Object)on that site. Otherwise packs those arguments and forwards tocallConstructor(Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Parameters:
receiver- the constructor's owner, as supplied by the callerarg1- the first constructor argumentarg2- the second constructor argumentarg3- the third constructor argumentarg4- the fourth constructor argument- Returns:
- the constructed object
- Throws:
Throwable- when construction fails
-
callGetProperty
Reads the property named bygetName()fromreceiverthrough the siteacceptGetProperty(Object)returns.- Specified by:
callGetPropertyin interfaceCallSite- Parameters:
receiver- the object whose property is read- Returns:
- the property value
- Throws:
Throwable- when the read fails
-
callGroovyObjectGetProperty
Reads the property named bygetName(). Anullreceiver is read fromNullObjectthroughInvokerHelper.getProperty(Object, String), and aGroovyRuntimeExceptionfrom that read is rethrown as the throwable fromScriptBytecodeAdapter.unwrap(GroovyRuntimeException). Any other receiver is read through the siteacceptGroovyObjectGetProperty(Object)returns.- Specified by:
callGroovyObjectGetPropertyin interfaceCallSite- Parameters:
receiver- the Groovy object whose property is read- Returns:
- the property value
- Throws:
Throwable- when the read fails
-
acceptGetProperty
Returns the property-read sitecreateGetPropertySite(Object)selects forreceiver. -
acceptGroovyObjectGetProperty
Returns the property-read sitecreateGroovyObjectGetPropertySite(Object)selects forreceiver. -
createGetPropertySite
Selects a property-read site forreceiver. Anullreceiver yields aNullCallSite. AGroovyObjectis passed tocreateGroovyObjectGetPropertySite(Object). AClassyields a class metaclass site. Any other receiver yields a POJO metaclass site. -
createGroovyObjectGetPropertySite
Selects a property-read site forreceiver. WhenGroovyObjectOverrides.hasCustomGetProperty(Class)isfalseandreceiver, cast toGroovyObject, has aMetaClassImplmetaclass, returns a POGO metaclass site. Otherwise aClassreceiver yields a class metaclass site, and any other receiver yields aPogoGetPropertySitethat calls the object's owngetProperty. -
getProperty
ThrowsUnsupportedOperationException. Property sites override this to read the property named bygetName().- Specified by:
getPropertyin interfaceCallSite- Parameters:
receiver- the object whose property is read- Returns:
- the property value
- Throws:
Throwable- when the read fails
-
callGetPropertySafe
- Specified by:
callGetPropertySafein interfaceCallSite- Parameters:
receiver- the object whose property is read; may be null- Returns:
- the property value, or null when
receiveris null - Throws:
Throwable- when the read fails
-
callGroovyObjectGetPropertySafe
- Specified by:
callGroovyObjectGetPropertySafein interfaceCallSite- Parameters:
receiver- the Groovy object whose property is read; may be null- Returns:
- the property value, or null when
receiveris null - Throws:
Throwable- when the read fails
-