Runs a method on an object and returns the result

@param obj the object to run the method on
@param methodName the name of the method
@return the results of the method run
4420
private static Object _runMethod(Object obj, String methodName)
    {
        try
        {
            Method sessionIdMethod = obj.getClass().getMethod(methodName);
            return sessionIdMethod.invoke(obj);
        }
        catch (Exception e)
        {
            return null;
        }

    }
124449
public static <T> T invokeMethod(final Object obj, Method method, Object... args) {
		try {
			return (T) method.invoke(obj, args);
		} catch (Exception e) {
			throw ExceptionUtil.unwrapAndUnchecked(e);
		}
	}
836745
@SuppressWarnings("unchecked")
    public static <R> R invoke(Object obj, String methodName, Class<?>[] parameterTypes,
                               Object... args) {
        Assert.isFalse(
            CollectionUtil.safeIsEmpty(parameterTypes) ^ CollectionUtil.safeIsEmpty(args),
            "方法参数类型列表必须和方法参数列表一致");
        Assert.isTrue(parameterTypes == null || parameterTypes.length == args.length,
            "方法参数类型列表长度必须和方法参数列表长度一致");
        Method method;
        if (obj instanceof Class) {
            method = getMethod((Class) obj, methodName, parameterTypes);
        } else {
            method = getMethod(obj.getClass(), methodName, parameterTypes);
        }
        return invoke(obj, method, args);
    }
209326
public static void print(final Object obj)
	{
		System.out.println(getInstance(obj.getClass()).serialise(obj));
	}
561756
def has_method(obj, name):
        
        if obj == None:
            raise Exception("Object cannot be null")
        if name == None:
            raise Exception("Method name cannot be null")

        name = name.lower()

        for method_name in dir(obj): 
            if method_name.lower() != name:
                continue

            method = getattr(obj, method_name)

            if MethodReflector._is_method(method, method_name):
                return True
        
        return False
952364
public static void callMethod(final Object obj, final String methodName, final Object... args) {
		try {
			callMethod(obj, methodName, false, args);
		} catch (InvocationTargetException e) {
			JK.throww(e);
		}
	}
475869
protected final Object getProperty(final Object obj, final String property) {
        if ((obj == null) || (property == null) || (property.trim().length() == 0)) {
            return null;
        }
        final String[] getterNames = createGetterNames(property);
        for (int i = 0; i < getterNames.length; i++) {
            final String getter = getterNames[i];
            try {
                final Class cl = obj.getClass();
                final Method m = cl.getMethod(getter, new Class[] {});
                return m.invoke(obj, new Object[] {});
            } catch (final IllegalAccessException e) {
                throw new RuntimeException("Accessing " + getter + " method of property '" + property + "' failed (private? protected?)! ["
                        + obj.getClass() + "]", e);
            } catch (final InvocationTargetException e) {
                throw new RuntimeException(
                        "Exception within " + getter + " method of property '" + property + "'! [" + obj.getClass() + "]", e.getCause());
            } catch (final NoSuchMethodException e) {
                if (i == getter.length() - 1) {
                    throw new RuntimeException("No " + getter + " method found for property! '" + property + "'! [" + obj.getClass() + "]",
                            e);
                }
            }
        }
        throw new IllegalStateException("No getters defined in 'createGetterNames()'!");
    }
1106851
public static Method findMethod(Object obj, String methodName, Object... params) {
        Class<?>[] classArray = new Class<?>[params.length];
        for (int i = 0; i < params.length; i++) {
            classArray[i] = params[i].getClass();
        }
        try {
            //look on all the public, protected, default and private methods of the class hierarchy.
            Class<?> klass = obj.getClass();
            while (klass != null) {
                for (Method method : klass.getDeclaredMethods()) {
                    //check if the method name matches along with the number of parameters
                    if (method.getName().equals(methodName) && method.getParameterCount() == classArray.length) {
                        Class<?>[] paramClasses = method.getParameterTypes();

                        //Then check one by one all the provided parameters and see if they match the defined ones.
                        boolean parametersMatch = true;
                        for(int i = 0; i < params.length; i++) {
                            if(!paramClasses[i].isAssignableFrom(classArray[i])) {
                                parametersMatch = false;
                                break;
                            }
                        }

                        if(parametersMatch) { //exact match, return the method
                            return method;
                        }
                    }
                }
                klass = klass.getSuperclass();
            }

            //nothing found
            throw new NoSuchMethodException();
        }
        catch (NoSuchMethodException ex) {
            throw new RuntimeException(ex);
        }
    }
210057
protected Object doInvokeMethod(String methodName, Object name, Object args) {
        super.doInvokeMethod(methodName, name, args);


        // return the completed node
        return lastCompletedNode;
    }
391341
function (object, returnName) {
        var methodName;
        for (methodName in this.methods) {
            if (!(object[methodName] instanceof Function)) {
                return returnName ? methodName : false;
            }
        }
        return true;
    }
1257119
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) {
        return delegate.invokeStaticMethod(object, methodName, arguments);
    }
894240
public static <T> Object callMethod(Object obj,
                                        Class<T> c,
                                        String name,
                                        Class<?>[] classes,
                                        Object[] args) {
        try {
            Method m = getMethod(c, name, classes);
            return m.invoke(obj, args);
        } catch(InvocationTargetException e) {
            throw getCause(e);
        } catch(IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }
624352
def getMethodByName(obj, name):

    
    try:#to get a method by asking the service
        obj = obj._getMethodByName(name)
    except:
        #assumed a childObject is ment 
        #split the name from objName.childObjName... -> [objName, childObjName, ...]
        #and get all objects up to the last in list with name checking from the service object
        names = name.split(".")
        for name in names:
            if nameAllowed(name):
                obj = getattr(obj, name)
            else:
                raise MethodNameNotAllowed()
        
    return obj
402604
@Override
    public void visitCode(Code obj) {
        try {
            for (JavaClass inf : guiInterfaces) {
                Method[] methods = inf.getMethods();
                for (Method m : methods) {
                    if (m.getName().equals(methodName) && m.getSignature().equals(methodSig)) {
                        listenerCode.put(obj, this.getMethod());
                        return;
                    }
                }
            }
            isListenerMethod = false;
            super.visitCode(obj);
        } catch (StopOpcodeParsingException e) {
            // method already reported
        }
    }
1337495
public static void callMethod(final Object obj, final String methodName, final boolean includePrivateMehtods, final Object... args)
			throws InvocationTargetException {
		final Class[] intArgsClass = initParamsClasses(args);
		try {
			Class<?> current = obj.getClass();
			Method method = null;
			while (current != Object.class) {
				try {
					method = current.getDeclaredMethod(methodName, intArgsClass);
					break;
				} catch (final NoSuchMethodException ex) {
					current = current.getSuperclass();
				}
			}
			if (method == null) {
				throw new NoSuchMethodException("Mehtod is not found in " + current);
			}
			method.setAccessible(true);
			method.invoke(obj, args);
		} catch (final InvocationTargetException e) {
			throw new InvocationTargetException(e.getCause());
		} catch (final Exception e) {
			throw new InvocationTargetException(e);
		}
	}
1096677
public Method getMethod(String methodName) {
        return checkNotNull(methods().get(checkNotNull(methodName)), 
        		"The method %s is not exists of object %s", methodName, delegateClass().getName());
    }
872119
public static Closure getMethodPointer(Object object, String methodName) {
        if (object == null) {
            throw new NullPointerException("Cannot access method pointer for '" + methodName + "' on null object");
        }
        return new MethodClosure(object, methodName);
    }