Loosen Constructor super()/this() call restrictions

Joseph D. Darcy Joe.Darcy at Sun.COM
Sun Mar 22 23:25:56 PDT 2009


Mike Duigou wrote:
> On Mar 22, 2009, at 6:14 PM, Mark Mahieu wrote:
>> 2009/3/23 Jeremy Manson <jeremy.manson at gmail.com> Also, it seems to  
>> me that you would want to be careful about access to
>> fields of the parent object before the invocation of super().
>> Jeremy
>> Yes, which implies no calls to other instance methods, or to static  
>> methods passing 'this' as an argument etc.  Maybe a simple rule to  
>> build upon would be to say that anything before the call to this()  
>> or super() is effectively in a static context (ie no references to  
>> instance members, or to this/super, are allowed).  There'd be more  
>> to it than that though.
> Your clarification is correct. Before the explicit call to super() or  
> this() no reference to instance fields or methods is allowed because  
> the object hasn't been created yet. The case where no explicit call to  
> super/this() is made is a little harder because an implicit call to  
> the no params super() method needs to be inserted before the first  
> reference to an instance field or method in order to construct the  
> object.
>> Also (Mike) there's at least one existing bug entry for this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4093999
> Hmmm, thanks! That should have been easy to find. Perhaps I searched  
> only open bugs.

While I've certainly chafed at the "must call super first rules," I 
don't think they are a severe enough annoyance to need addressing by 
Project Coin.

Additionally, a proposal on this topic should address the sort of points 
already raised by Jeremy as well as the issues listed in bug 4093999.


More information about the coin-dev mailing list