Call Method.invoke() when arguments in array
问题 I have the following interface: interface Foo { void bar(String a, int b); } I want to invoke Foo.bar (on an implementation of Foo) reflectively. However, the arguments are in array and i do not know the size of it. The following does not work: void gee(Foo someFoo, Method bar, Object[] args) { bar.invoke(someFoo, args); } That does not work because args is threated by the compiler as a single argument and the array is not "expanded" to vararg but is wrapped (internally) in one more array