From: <bc...@wo...> - 2001-04-25 18:58:38
|
On Wed, 25 Apr 2001 20:30:50 +0100, you wrote: >Eric, > >>I would like to integrate some jython into a java source tree. Some of my >>python modules will need to import classes defined in this project, and in >>at least one case, I need to implement a jython class with multiple >>inheritance from a java class and a java interface. How must I do this? > >Look under 'Interacting with java packages' at: >http://jython.sourceforge.net/docs/index.html > >You cannot directly use multiple inheritance from java classes or >interfaces. The workaround is to wrap the java things in Jython first: > >import pack1 # java packages on the class path when invoking jython. >import pack2 > >class wrapintf(pack1.someJavaInterface): > pass > # I don't know whether you actually have to implement the interface here. > >class wrapcls(pack2.someJavaClass): > pass > >class whatYouAskedFor(wrapcls, wrapintf): > pass You don't have to wrap the java classes/interfaces: class whatYouAskedFor(pack2.someJavaClass, pack1.someJavaInterface): def interface_method1(self): pass def interface_method2(self): pass will work as well. regards, finn |