Issue2375

classification
Title: super() fails to call Java superclass constructor
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.gronholm, darjus, santa4nt, zyasoft
Priority: high Keywords: patch

Created on 2015-07-06.02:34:20 by alex.gronholm, last changed 2015-09-09.20:14:35 by zyasoft.

Files
File name Uploaded Description Edit Remove
issue2375.patch darjus, 2015-09-01.12:27:58
Messages
msg10137 (view) Author: Alex Grönholm (alex.gronholm) Date: 2015-07-06.02:34:19
Why does this fail?
>>> from javax.swing.tree import DefaultTreeModel, DefaultMutableTreeNode, DefaultTreeCellRenderer
>>> class AModel(DefaultTreeModel):
...   def __init__(self):
...     super(AModel, self).__init__(DefaultMutableTreeNode())
... 
>>> a = AModel()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Default constructor failed for Java superclass javax.swing.tree.DefaultTreeModel

But this works:
>>> class AModel(DefaultTreeModel):
...   def __init__(self):
...     DefaultTreeModel.__init__(self, DefaultMutableTreeNode())
... 
>>> a = AModel()
>>>
msg10188 (view) Author: Darjus Loktevic (darjus) Date: 2015-09-01.07:01:20
I've tracked this to 95d09ba14aa7834f1e2cebcfb48593dc3b480f69 and http://bugs.jython.org/issue1540
msg10189 (view) Author: Darjus Loktevic (darjus) Date: 2015-09-01.12:27:58
Hey Jim,

Does this patch make sense? Sorry don't have much context into it, therefore would like your review before committing.
msg10197 (view) Author: Jim Baker (zyasoft) Date: 2015-09-01.23:38:54
Darjus, +1

Makes perfect sense: ProxyMaker handles constructors differently than ordinary methods because that is Java's model. So no need to prefix with super__

I have committed this patch on your behalf in https://hg.python.org/jython/rev/406ca703d7d3
msg10237 (view) Author: Alex Grönholm (alex.gronholm) Date: 2015-09-09.20:09:39
Just wanted to say, it works for me now. Thanks!
msg10238 (view) Author: Jim Baker (zyasoft) Date: 2015-09-09.20:14:35
Closing out per Alex's report.
History
Date User Action Args
2015-09-09 20:14:35zyasoftsetstatus: pending -> closed
messages: + msg10238
2015-09-09 20:09:39alex.gronholmsetmessages: + msg10237
2015-09-01 23:38:54zyasoftsetstatus: open -> pending
assignee: zyasoft ->
resolution: fixed
messages: + msg10197
milestone: Jython 2.7.1
2015-09-01 12:28:00darjussetfiles: + issue2375.patch
keywords: + patch
messages: + msg10189
2015-09-01 07:01:20darjussetnosy: + darjus
messages: + msg10188
2015-07-09 18:02:22santa4ntsetnosy: + santa4nt
type: crash -> behaviour
components: + Core
2015-07-06 02:34:20alex.gronholmcreate