From: Ype K. <yk...@xs...> - 2001-04-25 18:31:46
|
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 Off course you can add features to the wrappers before inheriting from them. >Finally, are jython objects serializable? I have never done this, but there is a pickle module as in CPython, iirc. In case you need Java serialisation: i don't know. > >A demo sourcetree of a trival hybrid jython & java program would be VERY >helpful. Have a look at Treedemo.py and Console.py in Demos/swing in the jython distribution. Definitely worth a look for everyone who ever used swing. Good luck, Ype |