调用指定对象的指定方法
@param obj 指定对象，不能为空，如果要调用的方法为静态方法那么传入Class对象
@param method 要调用的方法
@param args 参数
@param <R> 结果类型
@return 调用结果
967223
@SuppressWarnings("unchecked")
    public static <R> R invoke(Object obj, Method method, Object... args) {
        try {
            if (obj instanceof Class) {
                return (R) method.invoke(null, args);
            } else {
                return (R) method.invoke(obj, args);
            }
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new ReflectException("调用方法[" + method + "]失败", e);
        }
    }
626451
@Override
    public void visitCode(Code obj) {
        Method m = getMethod();

        if (m.isSynthetic()) {
            return;
        }

        String signature = m.getSignature();
        if (!signature.endsWith(")Ljava/lang/Object;")) {
            return;
        }
        stack.resetForMethodEntry(this);
        returnTypes.clear();
        super.visitCode(obj);
        if (returnTypes.size() <= 1) {
            return;
        }
        String methodName = m.getName();
        try {
            boolean isInherited = SignatureUtils.isInheritedMethod(currentClass, methodName, signature);

            int priority = NORMAL_PRIORITY;
            for (JavaClass cls : returnTypes.keySet()) {
                if ((cls != null) && Values.DOTTED_JAVA_LANG_OBJECT.equals(cls.getClassName())) {
                    priority = LOW_PRIORITY;
                    break;
                }
            }

            JavaClass cls = findCommonType(returnTypes.keySet());
            BugInstance bug;
            if (isInherited) {
                bug = new BugInstance(this, BugType.URV_INHERITED_METHOD_WITH_RELATED_TYPES.name(), priority).addClass(this).addMethod(this);
                if (cls != null) {
                    bug.addString(cls.getClassName());
                }
            } else if (cls == null) {
                bug = new BugInstance(this, BugType.URV_UNRELATED_RETURN_VALUES.name(), priority).addClass(this).addMethod(this);
            } else {
                bug = new BugInstance(this, BugType.URV_CHANGE_RETURN_TYPE.name(), priority).addClass(this).addMethod(this);
                bug.addString(cls.getClassName());
            }
            for (Integer pc : returnTypes.values()) {
                bug.addSourceLine(this, pc.intValue());
            }
            bugReporter.reportBug(bug);
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }
    }
1287267
@SuppressWarnings("unchecked")
  public static <E> E send(Object o, String methodName, Object... args) {
    try {
      for (Method method : o.getClass().getMethods()) {
        if (method.getName().equals(methodName)) {
          boolean isArgsMatched = true;
          for (int i = 0; i < method.getParameterTypes().length; i++) {
            if (i >= args.length || args[i] == null) continue;

            if (!isConvertable(method.getParameterTypes()[i],
                args[i].getClass()))
              isArgsMatched = false;
          }
          if (isArgsMatched && method.getParameterTypes().length == args.length)
            return (E) method.invoke(o, args);
        }
      }
      throw new NoSuchMethodException();
    } catch (NoSuchMethodException e) {
      logger.log(Level.SEVERE, null, e);
      throw new IllegalArgumentException("NoMethodError: undefined method `"
          + methodName + "' for " + o + ":" + o.getClass().getName());
    } catch (Exception e) {
      logger.log(Level.SEVERE, null, e);
      throw new RuntimeException(e);
    }
  }
1026228
private Consumer wrapVoidMethod(Method method) {
    return c -> {
      try {
        method.invoke(this, c);
      } catch (InvocationTargetException e) {
        throw new CommandException(e);
      } catch (IllegalAccessException e) {
        throw new AssertionError(e);
      }
    };
  }
862252
@Override
    public void visitMethod(Method obj) {
        if (Values.STATIC_INITIALIZER.equals(obj.getName())) {
            return;
        }

        if (state == State.COLLECT) {
            Type[] argTypes = obj.getArgumentTypes();
            for (Type t : argTypes) {
                addType(t);
            }
            Type resultType = obj.getReturnType();
            addType(resultType);
            LocalVariableTable lvt = obj.getLocalVariableTable();
            if (lvt != null) {
                LocalVariable[] lvs = lvt.getLocalVariableTable();
                if (lvs != null) {
                    for (LocalVariable lv : lvs) {
                        if (lv != null) {
                            Type t = Type.getType(lv.getSignature());
                            addType(t);
                        }
                    }
                }
            }
        } else {
            state = State.SEEN_NOTHING;
        }
        super.visitMethod(obj);
    }
1213496
public static Object callMethod(Object obj, String methodName, Object[] args) throws PageException {
	return callMethod(obj, KeyImpl.getInstance(methodName), args);
    }
392230
@Override
    public void visitMethod(Method obj) {
        Code c = obj.getCode();
        if (c != null) {
            byte[] opcodes = c.getCode();
            if (opcodes != null) {
                trPCPos = opcodes.length - 1;
                if (!obj.getSignature().endsWith(Values.SIG_VOID)) {
                    trPCPos -= 1;
                }
                trPCPos -= TAILRECURSIONFUDGE;
                possibleTailRecursion = true;
                isStatic = obj.isStatic();
                stack.resetForMethodEntry(this);
                super.visitMethod(obj);
            }
        }
    }
357976
function( object, method ) {
            return function(){
                var args = arguments;
                if ( args === undefined ){
                    args = [];
                }
                return method.apply( object, args );
            };
        }
1221287
public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
			final Object[] args) {
		Method method = getAccessibleMethod(obj, methodName, parameterTypes);
		if (method == null) {
			throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
		}

		try {
			return method.invoke(obj, args);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}
1020184
public static <T> T invokeMethod(Object obj, String methodName, Object... args) {
		Object[] theArgs = ArrayUtils.nullToEmpty(args);
		final Class<?>[] parameterTypes = ClassUtils.toClass(theArgs);
		return invokeMethod(obj, methodName, theArgs, parameterTypes);
	}
721650
public final String callMethod(String method) {
    parent.assertConnected();
    return debugger.callFunctionOnObject(method, objectId);
  }
655696
protected JSONArray callMethod(String method, Object ... args) throws Exception {
        return new QueryBuilder().retrieveResult(storedId).call(method, args).storeResult("LAST_" + getStoredId()).execute();
    }
951958
protected Object[] generateArguments (
        Method method, Object source, Object argument)
    {
        // figure out what sort of arguments are required by the method
        Class<?>[] atypes = method.getParameterTypes();

        if (atypes == null || atypes.length == 0) {
            return new Object[0];

        } else if (atypes.length == 1) {
            return new Object[] { source };

        } else if (atypes.length == 2) {
            if (argument != null) {
                return new Object[] { source, argument };
            }
            log.warning("Unable to map argumentless event to handler method that requires an " +
                        "argument", "controller", this, "method", method, "source", source);
        }

        // we would have handled it, but we couldn't
        return null;
    }
878987
private void processMethod(final Method method) {
    CommandArgument annotation = method.getAnnotation(CommandArgument.class);
    if (annotation != null) {
      final String name = method.getName();
      final Class<?>[] paramTypes = method.getParameterTypes();
      final Annotation[][] paramAnnotations = method.getParameterAnnotations();
      final ArgumentProcessor<Object[]> argProcessor = new ArgumentProcessor<Object[]>();
      final Object[] defaultParams = new Object[paramTypes.length];
      final List<Integer> positionalParams = new ArrayList<Integer>();

      String key = annotation.value();
      if (key.equals("")) {
        key = name;
      }

      for (int i = 0; i < paramAnnotations.length; i++) {
        Class<?> paramType = paramTypes[i];
        if (paramType == Integer.class || paramType == int.class) {
          defaultParams[i] = 0;
        } else if (paramType == Long.class || paramType == long.class) {
            defaultParams[i] = 0L;
        } else if (paramType == Double.class || paramType == double.class) {
          defaultParams[i] = 0.0;
        } else if (paramType == Float.class || paramType == float.class) {
          defaultParams[i] = (float) 0.0;
        } else if (paramType == String.class) {
          defaultParams[i] = "";
        } else if (paramType == File.class) {
          defaultParams[i] = null;
        } else if (paramType == Boolean.class || paramType == boolean.class) {
          defaultParams[i] = false;
        } else {
          throw new IllegalArgumentException("Invalid type (" + paramType.getCanonicalName() + ") for option parameter: method=" + method.getDeclaringClass().getCanonicalName() + "." + name);
        }

        int j;
        for (j = 0; j < paramAnnotations[i].length; j++) {
          if (paramAnnotations[i][j] instanceof OptionArgument) {
            OptionArgument optAnnotation = (OptionArgument) paramAnnotations[i][j];
            String optKey = optAnnotation.value();
            if (optKey.equals("")) {
              throw new IllegalArgumentException("OptionArgument on parameter requires key (method=`" + method.getDeclaringClass().getCanonicalName() + "." + name + "').");
            }

            char optShortKey = optAnnotation.shortKey();
            if (optShortKey == '\0') {
              optShortKey = optKey.charAt(0);
            }

            final int index = i;
            if (paramType == Integer.class || paramType == int.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Integer.parseInt(argq.remove());
                }
              });
            } else if (paramType == Long.class || paramType == long.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Long.parseLong(argq.remove());
                }
              });
            } else if (paramType == Boolean.class || paramType == boolean.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = true;
                }
              });
            } else if (paramType == String.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = argq.remove();
                }
              });
            } else if (paramType == Double.class || paramType == double.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Double.parseDouble(argq.remove());
                }
              });
            } else if (paramType == Float.class || paramType == float.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = Float.parseFloat(argq.remove());
                }
              });
            } else if (paramType == File.class) {
              argProcessor.addOption(optKey, optShortKey, new Command<Object[]>() {
                public void process(Queue<String> argq,
                    Object[] state) {
                  state[index] = new File(argq.remove());
                }
              });
            }

            break;
          }
        }

        // If there is no OptionArgument annotation, treat it as a
        // positional parameter.
        if (j >= paramAnnotations[i].length) {
          positionalParams.add(i);
        }
      }

      // The default command will parse out all the positional parameters
      // from what's left over after all the options have been processed.
      argProcessor.setDefaultCommand(new Command<Object[]>() {
        public void process(Queue<String> argq, Object[] state) {
          for (int index : positionalParams) {
            if (argq.isEmpty()) {
              break;
            }
            Class<?> paramType = paramTypes[index];
            if (paramType == Integer.class || paramType == int.class) {
              state[index] = Integer.parseInt(argq.remove());
            } else if (paramType == Long.class || paramType == long.class) {
              state[index] = Long.parseLong(argq.remove());
            } else if (paramType == Double.class || paramType == double.class) {
              state[index] = Double.parseDouble(argq.remove());
            } else if (paramType == Float.class || paramType == float.class) {
              state[index] = Float.parseFloat(argq.remove());
            } else if (paramType == String.class) {
              state[index] = argq.remove();
            } else if (paramType == File.class) {
              state[index] = new File(argq.remove());
            } else if (paramType == Boolean.class || paramType == boolean.class) {
              state[index] = Boolean.parseBoolean(argq.remove());
            } else {
              throw new UnexpectedException();
            }
          }
        }
      });

      // Add the command that processes its arguments and invokes the
      // method.
      addCommand(key, new Command<T>(){
        public void process(Queue<String> argq, T state) {
          Object[] params = defaultParams.clone();
          argProcessor.process(argq, params);
          try {
            method.invoke(state, params);
          } catch (IllegalArgumentException e) {
            throw new UnexpectedException(e);
          } catch (IllegalAccessException e) {
            throw new UnexpectedException(e);
          } catch (InvocationTargetException e) {
            throw new UnexpectedException(e);
          }
        }
      });
    }
  }
985354
public static Object invokeMethod(Object obj, String methodName, Object... params) {
        Method method = findMethod(obj, methodName, params);
        return invokeMethod(obj, method, params);
    }
416590
public static Object invoke(Object instance, Method method, Object... args) throws IllegalAccessException, InvocationTargetException {
        if (method.isVarArgs()) {
            args = fixVarArgs(method.getParameterTypes(), args);
        }
        return method.invoke(instance, args);
    }
542186
protected Method findMethod(Object obj,int functionId)
	{
		Method method=null;
		if(callTarget!=null)
		{
			Method[] methods=callTarget.getClass().getDeclaredMethods();
			for(Method m:methods)
			{
				CallBackFunction function=m.getAnnotation(CallBackFunction.class);
				if(function!=null && function.id()==functionId)
				{
					method=m;
					break;
				}
			}
		}
		return method;
	}