Class PackedClosureMetaClass
- All Implemented Interfaces:
MetaClass,MetaObjectProtocol,MutableMetaClass
PackedClosure, giving packed closures their own MOP
standing (the analog of ClosureMetaClass for generated closure classes, whose
per-class metaclasses packed closures deliberately do not have).
invokeMethod("call"/"doCall") dispatches straight to the adapter — a plain
virtual call that routes to the hosting class's dispatch tables — with no reflection
anywhere on the path, and, matching ClosureMetaClass, without consulting
categories for the closure-invocation names (categories have never applied to closure
doCall dispatch). Each fixed-arity family member class gets its own instance of
this metaclass from the registry (a per-class registry can only be per-adapter-class),
so class-level metaclass changes affect every packed closure of that member's arity;
per-instance setMetaClass is honoured as usual — the adapter's dispatch guard
routes perturbed instances through the replacement's invokeMethod.
respondsTo(Object, String, Object[]) is instance-faithful: the fixed-arity
family member's doCall(s) are erased to Object parameters (and
FixedN's is varargs), so the answer for the closure-invocation names is
additionally filtered by the instance's declared parameter types (which the adapter
carries for exactly this purpose). Purely class-level introspection
(pickMethod, getMetaMethods) necessarily reflects the shared adapter
class, not any single literal.
- Since:
- 6.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl
MetaClassImpl.MetaConstructor -
Field Summary
Fields inherited from class groovy.lang.MetaClassImpl
EMPTY_ARGUMENTS, getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninvokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) Invokes a method on the given receiver for the specified arguments.respondsTo(Object obj, String name, Object[] argTypes) Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.Methods inherited from class groovy.lang.MetaClassImpl
addMetaBeanProperty, addMetaMethod, addMetaMethodToIndex, addNewInstanceMethod, addNewStaticMethod, applyPropertyDescriptors, checkIfGroovyObjectMethod, checkInitalised, chooseConstructor, chooseMethod, chooseNamedArgCompatibleConstructor, clearInvocationCaches, createErrorMessageForAmbiguity, createTransformMetaMethod, doChooseMostSpecificParams, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getMethodWithCaching, getMethodWithCaching, getMethodWithoutCaching, getNonClosureOuter, getProperties, getProperty, getProperty, getRegistry, getStaticMetaMethod, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, handleMatches, hasCustomInvokeMethod, hasCustomStaticInvokeMethod, hasProperty, incVersion, initialize, invokeConstructor, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMethod, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, isPermissivePropertyAccess, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, pickMethod, reinitialize, respondsTo, retrieveConstructor, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setInitialized, setPermissivePropertyAccess, setProperties, setProperty, setProperty, toString
-
Constructor Details
-
PackedClosureMetaClass
-
-
Method Details
-
invokeMethod
public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) Description copied from class:MetaClassImplInvokes a method on the given receiver for the specified arguments. The sender is the class that invoked the method on the object. The MetaClass will attempt to establish the method to invoke based on the name and arguments provided.The isCallToSuper and fromInsideClass help the Groovy runtime perform optimisations on the call to go directly to the super class if necessary
- Specified by:
invokeMethodin interfaceMetaClass- Overrides:
invokeMethodin classMetaClassImpl- Parameters:
sender- The java.lang.Class instance that invoked the methodobject- The object which the method was invoked onmethodName- The name of the methodoriginalArguments- The arguments to the methodisCallToSuper- Whether the method is a call to a super class methodfromInsideClass- Whether the call was invoked from the inside or the outside of the class- Returns:
- The return value of the method.
- See Also:
-
respondsTo
Description copied from interface:MetaObjectProtocolReturns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
- Specified by:
respondsToin interfaceMetaObjectProtocol- Overrides:
respondsToin classMetaClassImpl- Parameters:
obj- The object to inspectname- The name of the method of interestargTypes- The argument types to match against- Returns:
- A List of MetaMethods matching the argument types which will be empty if no matching methods exist
- See Also:
-