I am attempting to write a method the executes a static method from another class by passing an array of strings as arguments to the method.
Here's what I have:
public static void
executeStaticCommand(final String[] command, Class<?> provider)
{
    Method[] validMethods = provider.getMethods();
    String javaCommand = TextFormat.toCamelCase(command[0]);
    for (Method method : validMethods) {
        if (method.getName().equals(javaCommand)) {
            try {
                method.invoke(null, new Object[] { new Object[] { command } });
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                Throwable ex = e.getCause();
                ex.printStackTrace();
            }
            break;
        }
    }
}
Such that this:
String[] args = new String[] { "methodName", "arg1", "arg2" }; 
executeStaticCommand(args, ClassName.class);
Should execute this:
public class ClassName {
    public static void methodName(String[] args) {
        assert args[1].equals("arg1");
    }
}
However I'm getting IllegalArgumentExceptions.
 
     
     
     
     
    