Search in sources :

Example 6 with MethodSelectionException

use of org.codehaus.groovy.runtime.metaclass.MethodSelectionException in project groovy by apache.

the class MetaClassImpl method pickStaticMethod.

private MetaMethod pickStaticMethod(String methodName, Class[] arguments) {
    MetaMethod method = null;
    MethodSelectionException mse = null;
    Object methods = getStaticMethods(theClass, methodName);
    if (!(methods instanceof FastArray) || !((FastArray) methods).isEmpty()) {
        try {
            method = (MetaMethod) chooseMethod(methodName, methods, arguments);
        } catch (MethodSelectionException msex) {
            mse = msex;
        }
    }
    if (method == null && theClass != Class.class) {
        MetaClass classMetaClass = registry.getMetaClass(Class.class);
        method = classMetaClass.pickMethod(methodName, arguments);
    }
    if (method == null) {
        method = (MetaMethod) chooseMethod(methodName, methods, MetaClassHelper.convertToTypeArray(arguments));
    }
    if (method == null && mse != null) {
        throw mse;
    } else {
        return method;
    }
}
Also used : NewInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod) NewMetaMethod(org.codehaus.groovy.runtime.metaclass.NewMetaMethod) MixinInstanceMetaMethod(org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod) NewStaticMetaMethod(org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod) GeneratedMetaMethod(org.codehaus.groovy.reflection.GeneratedMetaMethod) ClosureMetaMethod(org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod) TransformMetaMethod(org.codehaus.groovy.runtime.metaclass.TransformMetaMethod) MethodSelectionException(org.codehaus.groovy.runtime.metaclass.MethodSelectionException) CachedClass(org.codehaus.groovy.reflection.CachedClass) FastArray(org.codehaus.groovy.util.FastArray)

Aggregations

ClosureMetaMethod (org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod)6 MethodSelectionException (org.codehaus.groovy.runtime.metaclass.MethodSelectionException)6 MixinInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod)6 CachedClass (org.codehaus.groovy.reflection.CachedClass)4 GeneratedMetaMethod (org.codehaus.groovy.reflection.GeneratedMetaMethod)4 NewInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod)4 NewMetaMethod (org.codehaus.groovy.runtime.metaclass.NewMetaMethod)4 NewStaticMetaMethod (org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod)4 TransformMetaMethod (org.codehaus.groovy.runtime.metaclass.TransformMetaMethod)4 FastArray (org.codehaus.groovy.util.FastArray)4 MixinInMetaClass (org.codehaus.groovy.reflection.MixinInMetaClass)2 ParameterTypes (org.codehaus.groovy.reflection.ParameterTypes)2 ClosureStaticMetaMethod (org.codehaus.groovy.runtime.metaclass.ClosureStaticMetaMethod)2 MixedInMetaClass (org.codehaus.groovy.runtime.metaclass.MixedInMetaClass)2 OwnedMetaClass (org.codehaus.groovy.runtime.metaclass.OwnedMetaClass)2