by joachimma · 2y ago · 0 comments
I don't like the restriction on code before super. But I don't have a clue what they are referring to here. The code example doesn't use a template either.
PositiveBigInteger(long value) {
if (value <= 0)
new IllegalArgumentException("non-positive value");
super(value);
}Trivial method calls such as „toString“ can already cause issues and it’s worse once you want to guarantee certain value types properties.
class Sub extends Super {
int field = footgunA();
Sub() {
super(footgunB());
}
}
It's a zero merit headache factory and good intentions alone cannot change that.This is perfectly fine as far as I'm concerned.
[0] https://www.infoworld.com/article/3714933/jdk-23-the-new-fea...