Issue1540

classification
Title: Calling a protected Java method from a Python subclass causes recursion depth RuntimeError
Type: crash Severity: normal
Components: Versions: 2.5.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: WA, zyasoft
Priority: high Keywords:

Created on 2010-01-13.10:58:09 by WA, last changed 2010-08-31.06:01:43 by zyasoft.

Messages
msg5431 (view) Author: (WA) Date: 2010-01-13.10:58:09
This code crashes always on my machine:

from javax.swing import *

class PanelTest(JPanel):
    def paintComponent(self, g):
        super(PanelTest, self).paintComponent(g)

if __name__ == '__main__':
    frame = JFrame("Jython Swing Test")
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    pnl = PanelTest()
    frame.add(pnl)
    frame.pack()
    frame.setVisible(True)
msg5967 (view) Author: Jim Baker (zyasoft) Date: 2010-08-15.16:53:58
Also seen in trunk
msg6025 (view) Author: Jim Baker (zyasoft) Date: 2010-08-31.05:57:41
The workaround is to use super__PROTECTED_METHOD. This is an old form in Jython, that predates the use of the super function in Python 2.2.

Of course it's reasonable that super should simply work, or the alternative, to specify the super type directly, without super(), that is

JPanel.paintComponent(self, g)

But they don't, yet. This looks like a gap that opened when we implemented new-style classes in Jython, and made Java types new-style as well.

Presumably we need to look at modifying the code in or around org.python.core.PyReflectedFunction.
msg6026 (view) Author: Jim Baker (zyasoft) Date: 2010-08-31.06:01:43
In particular, this is related to our attempt to work around this issue:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957
History
Date User Action Args
2010-08-31 06:01:43zyasoftsetmessages: + msg6026
2010-08-31 05:57:42zyasoftsetmessages: + msg6025
title: super() causes 'maximum recursion depth exceeded' -> Calling a protected Java method from a Python subclass causes recursion depth RuntimeError
2010-08-22 22:42:10zyasoftsetpriority: high
2010-08-15 16:53:58zyasoftsetnosy: + zyasoft
messages: + msg5967
2010-01-13 10:58:09WAcreate