public class ConstructorSite
extends MetaClassSite
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.
| Modifiers | Name | Description |
|---|---|---|
static class |
ConstructorSite.ConstructorSiteNoUnwrap |
Call site where we know there is no need to unwrap arguments |
static class |
ConstructorSite.ConstructorSiteNoUnwrapNoCoerce |
Call site where we know there is no need neither unwrap nor coerce arguments |
static class |
ConstructorSite.NoParamSite |
Constructor site that, after the inherited checkCall(Object, Object[])
passes, invokes the cached constructor with an empty argument array
and then applies args[0] as a property map. |
static class |
ConstructorSite.NoParamSiteInnerClass |
Constructor site that, after the inherited checkCall(Object, Object[])
passes, invokes the cached constructor with only args[0] and
then applies args[1] as a property map. |
| Fields inherited from class | Fields |
|---|---|
class MetaClassSite |
metaClass |
class AbstractCallSite |
array, index, name |
| Constructor and description |
|---|
ConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params)Caches constructor and params, and records
metaClass's version for checkCall(Object, Object[]). |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Object |
callConstructor(Object receiver, Object[] args)When checkCall(Object, Object[]) passes, unwraps args
and calls CachedConstructor.doConstructorInvoke,
which coerces them. |
|
protected final boolean |
checkCall(Object receiver, Object[] args)Returns true when receiver is the meta-class's class,
the meta-class version is still the version recorded at construction,
and MetaClassHelper.sameClasses matches the
cached parameter classes to args. |
|
public static ConstructorSite |
createConstructorSite(CallSite site, MetaClassImpl metaClass, CachedConstructor constructor, Class[] params, Object[] args)Chooses a constructor site from args.
|
| Methods inherited from class | Name |
|---|---|
class AbstractCallSite |
acceptGetProperty, acceptGroovyObjectGetProperty, call, call, call, call, call, call, callConstructor, 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 |
Caches constructor and params, and records
metaClass's version for checkCall(Object, Object[]).
When checkCall(Object, Object[]) passes, unwraps args
and calls CachedConstructor.doConstructorInvoke,
which coerces them. A GroovyRuntimeException is rethrown via
ScriptBytecodeAdapter.unwrap.
Otherwise falls back to
CallSiteArray.defaultCallConstructor.
Returns true when receiver is the meta-class's class,
the meta-class version is still the version recorded at construction,
and MetaClassHelper.sameClasses matches the
cached parameter classes to args.
Chooses a constructor site from args.
When CachedConstructor.correctArguments returns the
same array and noWrappers(args) is true, returns a
ConstructorSiteNoUnwrap if noCoerce is true (its
callConstructor calls
CachedConstructor.doConstructorInvoke and skips
MetaClassHelper.unwrap) and a
ConstructorSiteNoUnwrapNoCoerce if noCoerce is false
(its callConstructor calls CachedConstructor.invoke
with no unwrap and no coerce).
If those argument checks fail, returns a ConstructorSite.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.