Loosen Constructor super()/this() call restrictions
Mike.Duigou at Sun.COM
Sun Mar 22 21:30:01 PDT 2009
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().
> 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
> 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.
More information about the coin-dev