I'll say the same thing I said in the last post - how is the first thing an error? Imagine we do it your way and have a class StaticThings. Then we have another object that uses it in a method:
class SpaceShuttle { void doSomethingThatCannotFail() { new StaticThings() {}.doSomething(); }
Now this code blows up at runtime, even though there is no actual problem. There's no real problem in any of the scenarios, by as long as we're signaling at compile time, it's fine to be a little overly paranoid. Once we get to runtime that's much riskier.
EDIT: missed the bit about the class being final. Why is the exception even necessary in this case? It can't ever be invoked.
-1
u/CubsThisYear Mar 04 '17
I'll say the same thing I said in the last post - how is the first thing an error? Imagine we do it your way and have a class StaticThings. Then we have another object that uses it in a method:
class SpaceShuttle { void doSomethingThatCannotFail() { new StaticThings() {}.doSomething(); }
Now this code blows up at runtime, even though there is no actual problem. There's no real problem in any of the scenarios, by as long as we're signaling at compile time, it's fine to be a little overly paranoid. Once we get to runtime that's much riskier.
EDIT: missed the bit about the class being final. Why is the exception even necessary in this case? It can't ever be invoked.