From: Iwan V. <iw...@gl...> - 2004-10-24 06:05:02
|
"Andre Burgaud" <an...@bu...> writes: > When a class A (Java or Jython) implements an interface I, the functions of > the interface I must be implemented in the class A. Therefore in your > samples, either the class A implements the interface and the method foo: Thanks Andre, I see what you mean (have not done java in years :-). But I realised that my problem is not that, its more complicated: The following works fine assuming the java code marked [java code] below: javac -d . I.java I2.java A.java run.java; java run If I substitute run.py (just above the java code) for run.java, and execute: javac -d . I.java I2.java A.java; jython run.py I get: foo Traceback (innermost last): File "run.py", line 10, in ? AttributeError: abstract method "bar" not implemented It gets more interesting - the following addition to run.py makes jython go into a busy-wait loop: <in class run> def bar(self): A.bar(self) #--[ run.py ]---------- import I2 import A class run(I2,A): def foo(self): print "foo" p = run() p.foo() p.bar() --------------------------------------------------[java code] //--[ I.java ]---------- public interface I { public void bar(); } //----------[ A.java ] public class A implements I { public void bar() { System.out.println("bar"); } } //--[ I2.java ]---------- public interface I2 extends I { public void foo(); } //--[ run.java ]---------- public class run extends A implements I2 { public void foo() { System.out.println("foo"); } public static void main(String[] args) { run p = new run(); p.foo(); p.bar(); } } In-Reply-To: <000001c4b773$fd743530$6501a8c0@minnesota> (Andre Burgaud's message of "Thu, 21 Oct 2004 08:43:41 -0500") User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Date: Sun, 24 Oct 2004 08:00:50 +0200 Message-ID: <87is904pv1.fsf@cave.home> |
From: Iwan V. <iw...@gl...> - 2004-10-25 11:50:18
|
Hi Andre, "Andre Burgaud" <an...@bu...> writes: > Actually, I'm a bit curious to know what you really try to achieve. Are you > looking for a specific application from the example your provided? :-) yes - I am trying to write a plugin for eclipse using jython using their GEF library. The example I have given is something I need to be able to do as dictated by the GEF framework. I have been programming in python and smalltalk for several years now, so I am resisting furiously having to think in Java again... And I have a lot of "model" (as in MVC) code in python that I do not want to port to java... But I have decided this weekend to give up and rewrite everything in java - the combination of learning curves and hairy little compatibility problems is getting a bit much... :-( >One > interesting example of implementing an Interface in Jython is described in > the Jython list archive > http://sourceforge.net/mailarchive/message.php?msg_id=2355194. > I haven't had time to look, will this week, tx. -i |