Issue504972
Created on 2002-01-17.17:53:54 by mhagger, last changed 2006-08-31.04:02:40 by cgroves.
Messages | |||
---|---|---|---|
msg550 (view) | Author: Michael Haggerty (mhagger) | Date: 2002-01-17.17:53:54 | |
A python class inheriting from JPanel and a java interface can't be instantiated because jython can't find one of the methods required by the interface. I tried to simplify the example below to use simple classes, but the error went away, so I suppose the complexity of JPanel plays a role. Example: Test.java: import java.awt.Container; public interface Test { Container getParent(); } test.py: import java.awt.Component import java.awt.Container import javax.swing.JPanel import Test class Error1(javax.swing.JPanel, Test): pass class Error2(javax.swing.JPanel, Test): def getParent(self): return None class OK1(java.awt.Container, Test): pass class OK2(java.awt.Component, Test): pass Error1() # doesn't work Error2() # doesn't work OK1() # works OK2() # works Neither Error1 nor Error2 can be instantiated; the error message is AttributeError: abstract method "getParent" not implemented Classes OK1 and OK2 can be instantiated without an error. I believe that the code is correct because the getParent() method inherited via java.awt.Component -> java.awt.Container -> javax.swing.JComponent -> javax.swing.JPanel should satisfy the interface requirement. Indeed, a class analogous to Error1 compiles and runs fine under java. Working around this problem is difficult because even Error2 fails. This problem exists under jython 2.0 and jython 2.1 with either Sun JDK 1.3.1 or IBM jikes 1.13 and IBMJava2-13 runtime. Yours, Michael |
|||
msg551 (view) | Author: Charlie Groves (cgroves) | Date: 2006-08-31.04:02:40 | |
Logged In: YES user_id=1174327 Looks like this is fixed in trunk. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2002-01-17 17:53:54 | mhagger | create |
Supported by Python Software Foundation,
Powered by Roundup