From: <bc...@wo...> - 2001-11-26 09:46:28
|
[Danny Yoo] >I've been experimenting with jythonc, and one of my experiments was to >play around with Java interfaces. In the course of my experiments, I've >been running my head into a strange AttributeError. > >Since I'm not too familiar with Jython, I'll report the steps I've done in >some detail; forgive me if much of this is extraneous! It is exactly the right amount of detail. Thank you for that. >The error message >is at the very bottom, and this message traces what I've done to get the >message. > >I have the following Java interface: [snipped a traditional use of jythonc which works] >And this worked! > >However, I ran into problems when I tried playing with my classes in >Jython. To force Jython to use my jythonc-compiled classes, I made a new >directory called "scratch". Here's the log: > >... >Jython 2.1a3 on java1.3.0_02 (JIT: null) >Type "copyright", "credits" or "license" for more information. >>>> import Doubler >>>> Doubler ><jclass Doubler at 5868800> >>>> d = Doubler() >>>> d.eval(42) >Traceback (innermost last): > File "<console>", line 1, in ? >AttributeError: abstract method "eval" not implemented >### > >I'm just scratching my head on this one. Are Jythonc-compiled classes >reusable from Jython itself? Short answer: no. It is because "Doubler" is partly a java class and partly a python module. To see Doubler function as a python module you can use this trick: import Doubler Doubler.moduleDictInit(Doubler.__dict__) d = Doubler.Doubler() print d.eval(42) There is no trick to make Doubler appear as a java class. The code that does that is located at the bottom half of Py.initProxy() and can't be called directly. regards, finn |