Title: Calling a protected Java method from a Python subclass causes recursion depth RuntimeError
Type: crash Severity: urgent
Components: Core Versions: Jython 2.7
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: Lai Dung, WA, fwierzbicki, santa4nt, zyasoft
Priority: high Keywords:

Created on 2010-01-13.10:58:09 by WA, last changed 2014-10-06.03:42:23 by zyasoft.

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")
    pnl = PanelTest()
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:
msg8165 (view) Author: Lai Dung (Lai Dung) Date: 2013-10-29.19:16:58
This issue still exists in v2.7 beta 1...

Simpler example:

    import java

    class D(java.util.Date):
        def toString(self):
            return super(D, self).toString()

Then you can reproduce the issue with:

>>> D()
msg9103 (view) Author: Jim Baker (zyasoft) Date: 2014-10-06.03:42:23
Target beta 4
Date User Action Args
2014-10-06 03:42:23zyasoftsetmessages: + msg9103
2014-09-26 05:53:22zyasoftsetresolution: accepted
2013-11-01 23:54:40santa4ntsetnosy: + santa4nt
2013-10-29 19:16:58Lai Dungsetnosy: + Lai Dung
messages: + msg8165
severity: normal -> urgent
components: + Core
versions: + Jython 2.7, - Jython 2.5
2013-02-25 18:40:01fwierzbickisetnosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.1
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