I use reflection to call a class method dynamically built at runtime :
public String createJDBCProvider(Object[] args)
Here's how:
Method m = adminTask.getClass().getMethod("createJDBCProvider", Object[].class);
id = (String) m.invoke(adminTask, new Object[]{ "a", "b", "c" });
IDEA warns me that I am guilty of redundant array creation for calling varargs method.
The method that I call actually accepts Object[], not Object ..., but they are probably equivalent and interchangeable, I think, so I'm moving forward.
At runtime, I get:
java.lang.IllegalArgumentException: wrong number of arguments
So it seems that mine Object[]is being passed as a sequence of Objects. Is that what is happening? If so, how can I make him not do this?
source
share