The expression for creating an instance of a class always creates a new object if the evaluation of its qualifier and arguments is performed normally, and if there is enough space to create the object. It doesn't matter if the constructor throws an exception; the object is still being created. In this case, the instantiation expression of the class is not executed normally, but when the exception is thrown.
However, you can still get a link to the new object. Consider the following:
public class C { static C obj;
Here, the link to the new object is stored elsewhere until an exception is thrown. If you run this program, you will see that the object is really not null, although its constructor did not complete normally.
Nathan ryan
source share