title: Passing varargs to Java from Python using Py4j
body: <p>I am trying to pass varargs to Java code from python. </p>
  
  <p>Java code :
  LogDebugCmd.java</p>
  
  <pre><code>public class LogDebugCmd implements Command {
    private Class clazz;
    private String format;
    private Object[] args;
  
    public LogDebugCmd() {}
    public void setLog(String format, Object... args) {
      this.format = format;
      this.args = args.clone();
      clazz = getClass();
    }
  
    @Override
    public void execute() {
      VLog.getLog(clazz).debug(format, args);
    }
  </code></pre>
  
  <p>CommandEntryPoint.java</p>
  
  <pre><code>public class CommandEntryPoint {
    private LogDebugCmd logDebugCmd;
  
    public CommandEntryPoint() {
      logDebugCmd = new LogDebugCmd();
  
    public LogDebugCmd getLogDebugCmd(String str, Object... args) {
      setLog(str, args);
      return logDebugCmd;
    }
    public static void main(String args[]) {
      GatewayServer gatewayServer = new GatewayServer(new CommandEntryPoint());
      gatewayServer.start();
      System.out.println("Gateway Server Started");
    }
  </code></pre>
  
  <p>Python code
  test.py:</p>
  
  <pre><code>from py4j.java_gateway import JavaGateway
  gateway = JavaGateway()
  logDebugCmd = gateway.entry_point.getLogDebugCmd("Step 01 - Test initiated.")
  logDebugCmd..execute()
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Python27/Lib/site-packages/py4j-0.10.3-py2.7.egg/py4j/sampleTLStest.py", line 4, in &lt;module&gt;
      logDebugCmd = gateway.entry_point.getLogDebugCmd("Step 01 - Test initiated.")
    File "C:\Python27\lib\site-packages\py4j-0.10.3-py2.7.egg\py4j\java_gateway.py", line 1133, in __call__
      answer, self.gateway_client, self.target_id, self.name)
    File "C:\Python27\lib\site-packages\py4j-0.10.3-py2.7.egg\py4j\protocol.py", line 323, in get_return_value
      format(target_id, ".", name, value))
  ***Py4JError: An error occurred while calling t.getLogDebugCmd. 
  Trace:
  py4j.Py4JException: Method getLogDebugCmd([class java.lang.String]) does not exist at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
  at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
  at py4j.Gateway.invoke(Gateway.java:272)
  at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
  at py4j.commands.CallCommand.execute(CallCommand.java:79)
  at py4j.GatewayConnection.run(GatewayConnection.java:214)
  at java.lang.Thread.run(Thread.java:745)***
  </code></pre>
  
  <p>Is there a way to pass varargs to Java ? I am trying to pass String as the second argument to getLogDebugCmd() which also errors out.</p>