I’m trying to use an instance of a java interface ( the interface is implemented in jython) in a java program.

 

Using the __tojava__ method I get a ‘java instance’ of the jython object but when I try to call a method of the

interface from java I get a “TypeError: login() too many arguments; expected 0 got 1

 

here’s the code I use.

 

      IJavaInterface myJythonObject = null;

 

      PythonInterpreter tInterp = new PythonInterpreter();

      Properties tPythonProperties = new Properties();

      tPythonProperties.setProperty("python.path", “c:/share/lib" );

      PythonInterpreter.initialize(System.getProperties(), tPythonProperties, null);

     

      try {

           

            File tFile = new File("c:/temp/test.py ");

            FileInputStream tFileStream = new FileInputStream(tFile);

            try {

 

                        tInterp.setErr(System.out);

                        tInterp.execfile(tFileStream);

                        tInterp.exec("x=TestClass()");

                        PyObject pObj1 = tInterp.get("x");

                        myJythonObject = (IjavaInterface)pObj1.__tojava__( IjavaInterface.class);

                       

                        myJythonObject.login();    ß-------this throws a TypeError: too many arguments

            }

            catch(Exception tEx) {

                        System.out.println(tEx.toString());

            }

      }

 

I have looked at previous postings on jython-user and googled the problem but I have not found a solution

I’m a jython newb so I probably either missed something or made some incorrect assumptions.

Should I not be using the myJythonObject like it is a java object?

I can use __findattr__(“login”) and use the __call__ method but this would defeat the purpose of the interface.

 

Any help would be greatly appreciated.

 

-stephane