public static List<Object[]> getMethodParams(Method method)
throws Exception {
ClassPool pool = ClassPool.getDefault();
pool.insertClassPath(new ClassClassPath(ClassUtils.class));
CtMethod cm = pool.getMethod(filterCGLIB(method.getDeclaringClass()
.getName()), method.getName());
CodeAttribute codeAttribute = cm.getMethodInfo().getCodeAttribute();
LocalVariableAttribute attr = (LocalVariableAttribute) codeAttribute
.getAttribute("LocalVariableTable");
List paramList = new ArrayList(cm.getParameterTypes().length);
// 非静态的成员函数的第一个参数是this
int pos = Modifier.isStatic(cm.getModifiers()) ? 0 : 1;
for (int i = 0; i < cm.getParameterTypes().length; i++) {
Object[] param = new Object[2];
param[0] = attr.variableName(i + pos);
param[1] = method.getParameterTypes()[i];
log.info("{},0:{},1:{}",i,param[0],param[1]);
paramList.add(param);
}
return paramList;
}
开发工具IDEA,用的jdk8
通过打印,看到获取到的参数多出了 exc,map,weiChatUser,this这四个参数,导致了参数值进行了错乱赋值,有没有哪位大虾能帮忙看下