3 ms·
Crazy that it took this long to allow parameter validation and transformation before calling super in the constructor. That was something that always bothered
by BlindEyeHalo 1y ago
Crazy that it took this long to allow parameter validation and transformation before calling super in the constructor.
That was something that always bothered me because it felt so counterintuitive.
- delusional 1y agoEspecially because you were always able to bypass it by declaring a `static` function and calling that as part of the parameters to `super`: public Foo(int x) { super(validate(x)); } validate would run before super, even though super was technically the first statement in the constructor, and the compiler was happy.
- mystifyingpoi 1y agoThis is such a funny workaround, I like that. But it doesn't matter in any library or your own code, since factory methods are much better (simply because they have names).
- PaulHoule 1y agoI've been programming in Java since before JDK 1.0 and that was one misfeature that bothered me then but that I've long since learned to work around.
- extraduder_ire 1y agoWasn't that possible since java 22?
- cesarb 1y ago> Wasn't that possible since java 22? From what I've seen, most people only care about the LTS versions of Java. Which means that after Java 21 LTS comes Java 25 LTS. The same happens with Ubuntu (after 22.04 LTS comes 24.04 LTS).