On Thu, Mar 5, 2009 at 10:45 AM, Qian Xu <quian...@stud.tu-ilmenau.de> wrote: > Hi Jarrett, > > but I need an exception here. This is an unexpected case. I want no instance > to be create in this case.
By the time the constructor runs, an instance has already been created. But if you throw an exception in the ctor, it's impossible for a reference to that instance to be stored anywhere, unless you store it within the ctor itself, i.e. this() { someGlobal = this; throw new Exception("foo!"); }