fix ReadClassDataTest
This commit is contained in:
@@ -200,7 +200,6 @@ public class ReadClassDataTest extends UsefulTestCase {
|
||||
|
||||
private static Object invoke(Method method, Object thiz, Object... args) {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
return method.invoke(thiz, args);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("failed to invoke " + method + ": " + e, e);
|
||||
@@ -229,7 +228,7 @@ public class ReadClassDataTest extends UsefulTestCase {
|
||||
sb.append("vararg ");
|
||||
serialize(valueParameter.getVarargElementType());
|
||||
} else {
|
||||
serialize(valueParameter.getOutType());
|
||||
serialize(valueParameter.getOutType(), sb);
|
||||
}
|
||||
if (valueParameter.hasDefaultValue()) {
|
||||
sb.append(" = ?");
|
||||
@@ -279,7 +278,7 @@ public class ReadClassDataTest extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private void serialize(Object o, StringBuilder sb) {
|
||||
private Method getMethodToSerialize(Object o) {
|
||||
// TODO: cache
|
||||
for (Method method : ReadClassDataTest.class.getDeclaredMethods()) {
|
||||
if (!method.getName().equals("serialize")) {
|
||||
@@ -295,12 +294,17 @@ public class ReadClassDataTest extends UsefulTestCase {
|
||||
continue;
|
||||
}
|
||||
if (method.getParameterTypes()[0].isInstance(o)) {
|
||||
invoke(method, this, o, sb);
|
||||
return;
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("don't know how to serialize " + o + " (of " + o.getClass() + ")");
|
||||
}
|
||||
|
||||
private void serialize(Object o, StringBuilder sb) {
|
||||
Method method = getMethodToSerialize(o);
|
||||
invoke(method, this, o, sb);
|
||||
}
|
||||
|
||||
private void serialize(ModuleDescriptor module, StringBuilder sb) {
|
||||
// nop
|
||||
|
||||
Reference in New Issue
Block a user