Message78
Consider the following script --
==========
#!/usr/bin/env jpython
from java.util import Date
class SubDate(Date):
def toString(self): return 'SubDate.toString() -> ' + Date.toString(self)
class SubSubDate(SubDate):
def toString(self): return 'SubSubDate.toString() -> ' +
SubDate.toString(self)
print Date().toString()
print SubDate().toString()
print SubSubDate().toString()
==========
The output is as follows --
==========
Fri Oct 22 12:53:58 CDT 1999
SubDate.toString() -> Fri Oct 22 12:53:58 CDT 1999
Traceback (innermost last):
File "test.py", line 12, in ?
File "test.py", line 8, in toString
File "test.py", line 6, in toString
java.lang.StackOverflowError
at org.python.core.PyClass.lookupGivingClass(PyClass.java:137)
at org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java:673)
at org.python.core.PyClass.lookup(PyClass.java:155)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:132)
< ... >
at org.python.proxies.SubDate$0.toString(Unknown Source)
at org.python.proxies.SubSubDate$1.super__toString(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:156)
< ... >
at org.python.proxies.SubDate$0.toString(Unknown Source)
at org.python.proxies.SubSubDate$1.super__toString(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:156)
< ... >
at org.python.util.jpython.main(jpython.java:123)
==========
What seems to happen is that SubSubDate.toString() calls SubDate.toString()
calls Date.toString() ... which then turns around and calls the derived-most
implementation of toString() all over again, ie, the one at SubSubDate. This
goes on and on until the above stack overflow occurs.
Note that with only one level of inheritance, ie, calling SubDate.toString(),
it worked correctly with no problems.
I originally observed this problem with overriding
java.lang.Thread.interrupt(),
so the above simplified test case has been reproduced elsewhere.
I can reproduce this with Sun Solaris JDK versions 1.3, 1.2.2 and 1.1.8.
|
|
Date |
User |
Action |
Args |
2008-02-20 17:16:40 | admin | link | issue222819 messages |
2008-02-20 17:16:40 | admin | create | |
|