>>>>> "Jim" == Jim Hazen <[EMAIL PROTECTED]> writes: [...] > In any case, the compiler (Blackdown 1.3.1 FCS) then returned with an > error saying that the call to 'this' must be the first statement in the > constructor (apparently the 'try' is now the first statement and this > isn't allowed).
> Can someone explain a bit more what's going on here? Is 'try' a > 'statement'? If there is a reason for this kind of error other than the > simple , "if the first token of the constructor body is checked and if > it's not 'this' and 'this' is seen later, throw an exception", kind of > thing I'd be interested in knowing what it is. > I ended duplicating code since I *really* didn't want to throw that type > of exception. Any suggestions how this might be handled in the future. > Any chance this 'this' restriction will be relaxed in further compilers > to allow for exception catching? (A) This isn't a Linux or Blackdown specific issue (and so should really be on one of the general Java mailing lists). (B) Yes, try[/catch/finally] is a "statement". (C) This requirement for the handling of "this" (and "super") invocations in constructors is covered explicitly by the JLS (v2) in section 12.5, Creation of New Class Instances. (D) I don't recall ever hearing anyone high up the Java food chain complain about this issue so I very highly doubt that it will ever be changed. (E) I suggest that you "homogenize" your constructors' declared exceptions. I.e., make all of them throw the same set of exceptions. The easy way to get into this habit is to just go one single step further than you already have -- i.e., make all of your constructors just wrappers around an internal helper method. I think it's bad design for different constructors of a class to throw different exceptions. [Since design also isn't on-topic for this list, feel free to continue this thread privately.] Happy New Year, John ---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]