NoSuchMethodException的意思是,没有这个方法。。- public Method getMethod(String name, Class<?>... parameterTypes)
- throws NoSuchMethodException, SecurityException {
- // be very careful not to change the stack depth of this
- // checkMemberAccess call for security reasons
- // see java.lang.SecurityManager.checkMemberAccess
- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
- Method method = getMethod0(name, parameterTypes);
- if (method == null) {
- throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
- }
- return method;
- }
复制代码 你调用的这个方法,Method method = getMethod0(name, parameterTypes);是这样获取的,错误在于第二个参数,第二个参数限定了参数类型,Object和String肯定有区别。
我只能这么理解了。。 |