Issue1540

classification
Title: Calling a Java method from a Python subclass via super() causes recursion depth RuntimeError
Type: crash Severity: urgent
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: Lai Dung, WA, alex.gronholm, fwierzbicki, santa4nt, zyasoft
Priority: high Keywords:

Created on 2010-01-13.10:58:09 by WA, last changed 2015-04-16.16:10:33 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
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
msg9745 (view) Author: Jim Baker (zyasoft) Date: 2015-04-01.00:46:31
Top priority for 2.7.1
msg9868 (view) Author: Jim Baker (zyasoft) Date: 2015-04-15.22:35:04
Fixed as of https://hg.python.org/jython/rev/95d09ba14aa7
msg9874 (view) Author: Jim Baker (zyasoft) Date: 2015-04-16.16:10:33
A
History
Date User Action Args
2015-04-16 16:10:33zyasoftsetstatus: pending -> closed
messages: + msg9874
2015-04-15 22:35:04zyasoftsetstatus: open -> pending
assignee: zyasoft
resolution: accepted -> fixed
messages: + msg9868
2015-04-01 01:29:53alex.gronholmsettitle: Calling a protected Java method from a Python subclass causes recursion depth RuntimeError -> Calling a Java method from a Python subclass via super() causes recursion depth RuntimeError
2015-04-01 00:46:32zyasoftsetmessages: + msg9745
2015-03-31 22:15:22alex.gronholmsetnosy: + alex.gronholm
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