The method I want to invoke (I know it's public but I need to use reflection):
public byte[] myMethod()
I get the Method
object like this and m
contains myMethod()
(I checked with the debugger)
Method m = Class.forName(MyClass.class.getName()).getDeclaredMethod("myMethod");
Finally I need to invoke m and pass the result to an object:
byte[] myBytes = null;
m.invoke(myBytes);
No exception is thrown but myBytes
stays null... I also tried the following without more success:
m.invoke(myBytes, (Object[])null);
How can I get the result of the invocation to myBytes?