Try creating the below class and setting a breakpoint in the non-static initializer block. Now try creating the class using each of the three constructors. In all cases the initializer is called, but the IDE only stops at the breakpoint in the case where the first constructor is called. At first I assumed that this was because it was the no-args constuctor, but then I re-ordered the constuctors in the code and the break-point worked for whichever constructor is first (only).
This is consistent with something I read about non-static initializer code being "copied into each constructor by the compiler" - so it would seem that the break point is set only the in the first constructor and not in the others.
<code>
package scratch;
public class Happy {
private static boolean isWeekend() {
return true; // whatever (btw, breakpoint here always respected, always reached)
}
private boolean playDay;
private boolean withCreamOnTop;
{
playDay = isWeekend(); // set breakpoint here
}
public Happy() {
this.withCreamOnTop = false;
}
public Happy(boolean withCreamOnTop) {
this.withCreamOnTop = withCreamOnTop;
}
public Happy(int withCreamOnTop2) {
this.withCreamOnTop = withCreamOnTop2==2;
}
}
</code>