0
스칼라에서 메서드를 반사적으로 호출하려고합니다. 그러나 인수가 메서드 시그니처와 일치하는 것처럼 보일지라도 잘못된 개수의 예외가 계속 발생합니다.스칼라 : 잘못된 인수 개수 메서드 호출시 예외가 발생했습니다.
class ReflectionTest {
def myConcat (s1:String, s2:String, s3:String): String = {
return s1 + s2 + s3
}
@Test
def testReflectiveConcat = {
val s = myConcat ("Hello", "World", "Now")
val methods = new ReflectionTest().getClass().getDeclaredMethods
for (method <- methods) {
if (method.getName().startsWith("myConcat")) {
// this throws IllegalArgumentException: wrong number of arguments
val r = method.invoke(new ReflectionTest(), Array("Hello", "World", "Bye"))
println (r)
}
}
}
}