ClassB must have a static method
public static ClassB makeClassB() { try { return new ClassB(); } catch(Exception exc) {
which completes the construction of ClassB with try / catch. The client code will call makeClassB() , and the constructor - ClassB will be private and throwing.
source share