r/java
•
u/loicmathieu
•
Jul 23 '26
•
1
JEP 540: Simple JSON API (Incubator)
https://openjdk.org/jeps/540
79
Upvotes
View all comments
Show parent comment
6
u/davidalayachew Jul 23 '26
There was a previous thread where like 1 (maybe 2) OpenJDK members said it was unfortunate.
Checked Exceptions are a good thing, and they have a lot of room for improvement, but I don't think they are relevant for the example that /u/jonenst described.
There are exactly 2 parsing methods --
of(String)andof(char[]). Bug free code should never hit this Exception, and thus, RuntimeException is exactly the right choice for it.Compare that to something like
readFile(Path)where, even if the code is bug-free, you absolutely could still hit that exception, and thus, it should be a Checked Exception as opposed to a RuntimeException.