Title: Can't invoke Java method that takes a variable number of arguments with zero arguments
Type: Severity: normal
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: akong, alex.gronholm, zyasoft
Priority: Keywords:

Created on 2010-05-29.12:48:38 by alex.gronholm, last changed 2010-06-16.14:47:39 by zyasoft.

msg5784 (view) Author: Alex Grönholm (alex.gronholm) Date: 2010-05-29.12:48:37
public class Test {
  public void test(String... args) {

Python code (
import Test

Traceback (most recent call last):
  File "", line 3, in <module>
TypeError: test(): expected 1 args; got 0
msg5803 (view) Author: Jim Baker (zyasoft) Date: 2010-06-14.19:45:22
This specific call is managed by org.python.core.PyReflectedFunction
msg5804 (view) Author: Jim Baker (zyasoft) Date: 2010-06-14.21:53:15
PyReflectedFunction and supporting classes do not take in account that a Java method may be using varargs. Because varargs is simply a form of autoboxing, it's possible to still invoke through a workaround. Using the example code submitted by Alex, this would look like:

t = Test()
t.test([]) # instead of t.test()
t.test(["abc", "xyz"]) # instead of t.test("abc", "xyz")
# etc
msg5814 (view) Author: Jim Baker (zyasoft) Date: 2010-06-16.14:47:39
Fixed by r7066
Date User Action Args
2010-06-16 14:47:39zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg5814
2010-06-14 21:53:16zyasoftsetassignee: zyasoft
messages: + msg5804
2010-06-14 19:45:23zyasoftsetnosy: + zyasoft
messages: + msg5803
2010-06-01 20:22:23akongsetnosy: + akong
2010-05-29 12:48:38alex.gronholmcreate