Issue649582
Created on 2002-12-06.15:43:00 by xks, last changed 2013-02-26.21:45:00 by fwierzbicki.
Messages | |||
---|---|---|---|
msg797 (view) | Author: kevin seguin (xks) | Date: 2002-12-06.15:43:00 | |
if you try to subclass a java class in jython, and that java class has a protected constructor and that java class's superclass also has a protected constructor, you will get an AttributeError, unless you set Dpython.security.respectJavaAccessibility to false. for example: abstract public class Super { protected Super() { } } abstract public class Super2 extends Super { protected Super2() { super(); } } class pySubclass(Super2): def __init__(self): Super2.__init__(self) x=pySubclass() |
|||
msg798 (view) | Author: Deleted User leouserz (leouserz) | Date: 2007-01-16.18:50:23 | |
arghhh... ! This is a maddening problem. It seems that the PyReflectedConstructor being returned for the Super one is the Object constructor. It finds it in its bases. In Super2 it doesn't find it and things go bad. This is ugly, the real direct constructor call does not go against the Super2.__init__, this appears to be redirected to the pySubclass java constructor which can invoke the protected constructor. Too much dancing around... leouser |
|||
msg799 (view) | Author: Deleted User leouserz (leouserz) | Date: 2007-01-16.20:10:44 | |
patches for this are here: http://sourceforge.net/tracker/index.php?func=detail&aid=1637085&group_id=12867&atid=312867 I decided to follow the formula for the instance that worked: 1. If not constructors, return constructor for Object.class 2. In Object.class constructor, if it is invoked with a PyJavaClass who does not have an __init__, throw an TypeException. I like this better than a NullPointerException, which occurs if the superclass has a private constructor. |
|||
msg800 (view) | Author: Charlie Groves (cgroves) | Date: 2007-04-18.07:59:33 | |
Leo's patch makes Super2.__init__ return java.lang.Object's constructor. Calling Super2.__init__(self) from pySubclass only works because PyReflectedConstructor's __call__ interally looks up the proxy class of self which has access to the protected constructor. I don't think that's any better than the problem the patch fixes. It exposes incorrect information and it's really confusing code. We're essentially hosed here because subclasses calling protected constructors is a partial visibility concept Python just doesn't have. Maybe we could make the Python super builtin give access to the proxy class's dict if called with a PyJavaClass? |
History | |||
---|---|---|---|
Date | User | Action | Args |
2013-02-26 21:45:00 | fwierzbicki | set | versions: + Jython 2.7 |
2009-03-03 18:04:50 | fwierzbicki | set | nosy: + fwierzbicki |
2002-12-06 15:43:00 | xks | create |
Supported by Python Software Foundation,
Powered by Roundup