4 ms·
The friction between the benefits of detecting errors statically, handling them quickly, and the diversity of needs for error handling cannot be avoided with an
by w10-1 3y ago
The friction between the benefits of detecting errors statically, handling them quickly, and the diversity of needs for error handling cannot be avoided with any fixed policy like "unchecked only".
This tool does remind us that checked exceptions in Java are a compile-time phenomenon only, so (non-compliant) compilers can be made to ignore them. Neat, but... helpful? It would certainly lock you into using the tool.
Instead, we need configurable policies for error handling, where the same code can be statically analyzed much more deeply (e.g., to include unchecked exceptions) or run more leniently (e.g., when exceptions are used only for flow control). Some of this might pertain to local declarations, and some might be policies of various scopes (per VM, per-package, or per call-chain), and would probably fold in assertions and fibers/virtual threads and some OS-sensitive behaviors. The goal would be to write the code once (with full disclosure, i.e., only check-able exceptions and assertions), but to reuse the same code under different policies.
Whether anyone wants to do the work of folding this into the VM as security privileges were is another question...
- smrtinsert 3y agoAgreed. I absolutely prefer checked exceptions since it forces devs and consequently business to develop requirements for possibilities. Lack of ambiguity helps me sleep at night. Potential runtime errors do not.
- riku_iki 3y agoThe issue with checked exceptions in Java is that they are not supported in java lambda syntax and library functions.
- masklinn 3y agoMore generally the problem of checked exceptions in Java is that they are not supported by Java. That was an issue right from the start, and it only got worse as the type system got richer.
- riku_iki 3y ago> More generally the problem of checked exceptions in Java is that they are not supported by Java. would you elaborate this statement?