Alex Grönholm | 17 Mar 22:33
Picon
Gravatar

Re: Inheriting from a Java class with no default constructor

17.3.2010 21:41, Jeff Emanuel kirjoitti:
> By passing self as the second argument to
> PropertyChangeSupport.__init__, you are trying
> to pass an unconstructed object.  You need a
> different Object for the second argument.  You
> can't do that in Java either.  The following
> equivalent Java code fails to compile with this
> error:
>
>
> cannot reference this before supertype constructor has been called
>     super(this);
>           ^
>
> import java.beans.PropertyChangeSupport;
> public class PCS extends PropertyChangeSupport {
>   public PCS() { super(this); }
> }
Yup, you are right. I guess I've been out of touch from Java for too 
long not to see this.
Inheriting from PropertyChangeSupport would have been a nice shortcut to 
providing bound properties support that Java code could also access.
>
>
>
> Alex Grönholm wrote:
>> How can I inherit from a Java class that doesn't have a default
>> constructor? If I try this:
>>
>> from java.beans import PropertyChangeSupport
>>
>> class A(PropertyChangeSupport):
>>      def __init__(self):
>>          PropertyChangeSupport.__init__(self, self)
>>
>> A()
>>
>> I get: TypeError: Default constructor failed for Java superclass
>> java.beans.PropertyChangeSupport
>>
>> Is this impossible, or am I doing something wrong? Or is there a bug
>> in Jython?
>> This was tested on SVN trunk.
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users <at> lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jython-users

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

Gmane