Hi Stuart,
Thanks for the reply. I will tell my understanding of the quoted JLS Sentence.
It is compile-time error if an instance initializer of a named class can throw a
checked exception unless that exception or one of its supertypes is explicitly
declared in the throws clause of each constructor of its class and the class has at
least one explicitly declared constructor
In order to throw a checked exception from Instance Intializer following conditions needs to be statisfied
1) At Least One explicitly declared Constructor Say HHH() in this case has to be present
2) The Same that is HHH() Constructor has to throws A Exception or the Exceptions Super Type, so declared the constructor like following
If above conditions are satisfied, you can have an instance intializer block that can throw a Checked Exception like following
I am not able to relate my understanding with your code, to be specific i am not able to understand why you have kept if block in instance intializer. If i am not wrong, statements under conditional checking block will be executed only on certain condition or conditions, which may or may not happen,thats why that compilation problem has resolved.