Loosen Constructor super()/this() call restrictions

Howard Lovatt howard.lovatt at iee.org
Thu Mar 26 17:28:14 PDT 2009


Hi,

I am not understanding your example, what is Bar if its not B - where
is its definition.

Also my suggestion isn't saying that the super constructor can't
access the super class fields or that after calling super you can't
access super fields, just that before calling super you can't access
super fields (only this.field_name). Also note that you can't call an
instance method, at all, before super, not even this.method_name( ...
).

Howard.

2009/3/27 Marek Kozieł <develop4lasu at gmail.com>:
> 2009/3/24 Howard Lovatt <howard.lovatt at gmail.com>:
>> I don't get the example. Is class B meant to be Bar? Can you clarify?
>>
>> -- Howard.
>>
>
> No, B is B.
> I wanted show the problem:
> public B(Bar bar, Foo foo) {
>        super(bar);
>        this.foo = foo;
>     }
> mean in runtime:
>        this.bar = bar;
>        this.foo = bar.foo;
>        this.foo = foo;
>
>
> public B(Bar bar, Foo foo) {
>        this.foo = foo;
>        super(bar);
>     }
> mean in runtime:
>        this.foo = foo;
>        this.bar = bar;
>        this.foo = bar.foo;
>
> While second constructor look really innocent.
> --
> Pozdrowionka. / Regards.
> Lasu aka Marek Kozieł
>
> http://lasu2string.blogspot.com/
>



-- 
  -- Howard.



More information about the coin-dev mailing list