Back to the original question....
Try this:
This is a little bit better, since a cut-and-paste of the if(log == null){...} section would throw a compile time error if the
Test class cannot be found--of course, if you are in the same package or in a subclass, then you still have the problem.
I would therefore have the boilerplate in a separate text file and have a holder inplace of the new Test() command -- possibly: new _some_class_(). That way, it would garunteedly not compile. Unfortunately (or fortunately?) the developers of Java did not see the need for a way to access the class name inside of a static context. As only cut-and-paste coding would require this, perhaps its a good thing. But it assuredly makes things more difficult.
Note that this can also get expensive if the constructor takes a lot of resources--you are essentially creating a "throw-away" object here. I suggest having a separate init() method if you do do this, so that your calls to the constructor are not so expensive.
[ July 22, 2003: Message edited by: Joel McNary ]