JSR223 Access Python class instances through Java

Jared Klumpp jaredatwork0 at gmail.com
Thu Nov 12 22:25:41 CET 2009


I am trying to access (from Java) a python class that extends a Java
interface. The following program runs fine in the jython console (I
can instantiate Tada, call t.getName() and everything prints
correctly.) However, if I invoke test1() from Java using JSR223, the
returned object is inaccessible (proxy type) and none of the "in
init", "in getName" strings will print.

Furthermore, none of the lines print unless I convert ITest to a
concrete class, but then the getName methods return the concrete
implementation's string.

Has anyone successfully had this situation work, and how did you do
it?

Thanks in advance

Code:
===========
import ITest

class Tada(ITest):
        def __init__(self):
                print "In Init"

        def getName(self):
                print "In getName"
                return "Joe Schmoe"


def test1():
        t = Tada()
        print t.getName()
        print "Hello, World"
        return t




More information about the Python-list mailing list