|
From: Michael H. <hag...@jp...> - 2002-01-23 19:17:31
|
Hi,
I reported this bug to the bug tracker a few days ago, but it doesn't
seem to get much activity so I hope you don't mind my reposting it
here.
I have to decide in the next couple of days whether to move more of my
company's project to Jython or to leave it as naked Java. This minor
Jython bug has proved to be an irritation in the experimental Jython
conversion.
A Jython class inheriting from both JPanel and a java interface can't
be instantiated because jython can't find one of the methods required
by the interface and supplied by the class. Moreover, the method
can't even be explicitly defined in the derived class for some reason.
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 class Error1 nor class 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, all under Linux.
Thanks for Jython! Regardless of whether we end up writing large
parts of our project in Jython, it has been invaluable for testing,
scripting, and prototyping.
Yours,
Michael
--
Michael Haggerty
JPK Instruments
hag...@jp...
|