提交 ee6b0804 authored 作者: Thomas Mueller's avatar Thomas Mueller

assertThrows

上级 db009ce0
...@@ -165,6 +165,13 @@ public class ProxyCodeGenerator { ...@@ -165,6 +165,13 @@ public class ProxyCodeGenerator {
} }
private static String getClassName(Class<?> c) { private static String getClassName(Class<?> c) {
return getClassName(c, false);
}
private static String getClassName(Class<?> c, boolean varArg) {
if (varArg) {
c = c.getComponentType();
}
String s = c.getSimpleName(); String s = c.getSimpleName();
while (true) { while (true) {
c = c.getEnclosingClass(); c = c.getEnclosingClass();
...@@ -173,6 +180,9 @@ public class ProxyCodeGenerator { ...@@ -173,6 +180,9 @@ public class ProxyCodeGenerator {
} }
s = c.getSimpleName() + "." + s; s = c.getSimpleName() + "." + s;
} }
if (varArg) {
return s + "...";
}
return s; return s;
} }
...@@ -249,13 +259,14 @@ public class ProxyCodeGenerator { ...@@ -249,13 +259,14 @@ public class ProxyCodeGenerator {
} }
writer.print(getClassName(retClass) + writer.print(getClassName(retClass) +
" " + m.getName() + "("); " " + m.getName() + "(");
int i = 0; Class<?>[] pc = m.getParameterTypes();
for (Class<?> p : m.getParameterTypes()) { for (int i = 0; i < pc.length; i++) {
Class<?> p = pc[i];
if (i > 0) { if (i > 0) {
writer.print(", "); writer.print(", ");
} }
writer.print(getClassName(p) + " p" + i); boolean varArg = i == pc.length - 1 && m.isVarArgs();
i++; writer.print(getClassName(p, varArg) + " p" + i);
} }
writer.print(")"); writer.print(")");
Class<?>[] ec = m.getExceptionTypes(); Class<?>[] ec = m.getExceptionTypes();
...@@ -297,7 +308,7 @@ public class ProxyCodeGenerator { ...@@ -297,7 +308,7 @@ public class ProxyCodeGenerator {
".class.getDeclaredMethod(\"" + m.getName() + ".class.getDeclaredMethod(\"" + m.getName() +
"\","); "\",");
writer.print(" new Class[] {"); writer.print(" new Class[] {");
i = 0; int i = 0;
for (Class<?> p : m.getParameterTypes()) { for (Class<?> p : m.getParameterTypes()) {
if (i > 0) { if (i > 0) {
writer.print(", "); writer.print(", ");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论