3 ms·
super() was never forced to be placed at the start. Every expression that you call in super was called before it, obviously. So you always was writing code li
by vbezhenar 4y ago
super() was never forced to be placed at the start.
Every expression that you call in super was called before it, obviously.
So you always was writing code like
MyCtor() {
int arg1 = calcArg1();
int arg2 = calcArg2();
super(arg1, arg2);
}
And the fact that you wasn't able to write this code literally was confusing for every beginner.
Right now the rule is simple as it should be: you can't read `this`, explicitly or implicitly, before calling `super()`. Now it actually makes sense.
The only somewhat confusing thing about this JEP is that you can initialize fields before calling super. I don't see why this is needed and I'd treat it as code smell. I've read that example and I don't think that it's convincing. This code should be rewritten.