Class ConstructorSite
java.lang.Object
org.codehaus.groovy.runtime.callsite.AbstractCallSite
org.codehaus.groovy.runtime.callsite.MetaClassSite
org.codehaus.groovy.runtime.callsite.ConstructorSite
- All Implemented Interfaces:
CallSite
- Direct Known Subclasses:
ConstructorSite.ConstructorSiteNoUnwrap,ConstructorSite.ConstructorSiteNoUnwrapNoCoerce
Call site bound to one
CachedConstructor.
callConstructor invokes that constructor when the receiver is the meta-class's
class, the meta-class version is unchanged, and the argument classes still match.
Otherwise it falls back to the default constructor call.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCall site where we know there is no need to unwrap argumentsstatic classCall site where we know there is no need neither unwrap nor coerce argumentsstatic classConstructor site that, after the inheritedcheckCall(Object, Object[])passes, invokes the cached constructor with an empty argument array and then appliesargs[0]as a property map.static classConstructor site that, after the inheritedcheckCall(Object, Object[])passes, invokes the cached constructor with onlyargs[0]and then appliesargs[1]as a property map. -
Field Summary
Fields inherited from class org.codehaus.groovy.runtime.callsite.MetaClassSite
metaClassFields inherited from class org.codehaus.groovy.runtime.callsite.AbstractCallSite
array, index, name -
Constructor Summary
ConstructorsConstructorDescriptionConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params) -
Method Summary
Modifier and TypeMethodDescriptioncallConstructor(Object receiver, Object[] args) WhencheckCall(Object, Object[])passes, unwrapsargsand callsCachedConstructor.doConstructorInvoke(Object[]), which coerces them.protected final booleanReturnstruewhenreceiveris the meta-class's class, the meta-class version is still the version recorded at construction, andMetaClassHelper.sameClasses(Class[], Object[])matches the cached parameter classes toargs.static ConstructorSitecreateConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params, Object[] args) Chooses a constructor site fromargs.Methods inherited from class org.codehaus.groovy.runtime.callsite.AbstractCallSite
acceptGetProperty, acceptGroovyObjectGetProperty, call, call, call, call, call, call, callConstructor, callConstructor, callConstructor, callConstructor, callConstructor, callCurrent, callCurrent, callCurrent, callCurrent, callCurrent, callCurrent, callGetProperty, callGetPropertySafe, callGroovyObjectGetProperty, callGroovyObjectGetPropertySafe, callSafe, callSafe, callSafe, callSafe, callSafe, callSafe, callStatic, callStatic, callStatic, callStatic, callStatic, callStatic, createGetPropertySite, createGroovyObjectGetPropertySite, getArray, getIndex, getName, getProperty
-
Constructor Details
-
ConstructorSite
public ConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params)
-
-
Method Details
-
callConstructor
WhencheckCall(Object, Object[])passes, unwrapsargsand callsCachedConstructor.doConstructorInvoke(Object[]), which coerces them. AGroovyRuntimeExceptionis rethrown viaScriptBytecodeAdapter.unwrap(GroovyRuntimeException). Otherwise falls back toCallSiteArray.defaultCallConstructor(CallSite, Object, Object[]).- Specified by:
callConstructorin interfaceCallSite- Overrides:
callConstructorin classAbstractCallSite- 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
-
checkCall
Returnstruewhenreceiveris the meta-class's class, the meta-class version is still the version recorded at construction, andMetaClassHelper.sameClasses(Class[], Object[])matches the cached parameter classes toargs. -
createConstructorSite
public static ConstructorSite createConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params, Object[] args) Chooses a constructor site fromargs. WhenParameterTypes.correctArguments(Object[])returns the same array andnoWrappers(args)is true, returns aConstructorSite.ConstructorSiteNoUnwrapifnoCoerceis true (itscallConstructorcallsCachedConstructor.doConstructorInvoke(Object[])and skipsMetaClassHelper.unwrap(Object[])) and aConstructorSite.ConstructorSiteNoUnwrapNoCoerceifnoCoerceis false (itscallConstructorcallsCachedConstructor.invoke(Object[])with no unwrap and no coerce). If those argument checks fail, returns aConstructorSite.
-