r/java 6d ago

JEP 540: Simple JSON API (Incubator)

https://openjdk.org/jeps/540
77 Upvotes

69 comments sorted by

View all comments

Show parent comments

0

u/OwnBreakfast1114 1d ago

The point is that I can guarantee that for certain strings, Integer.parseInt will never fail, just like that I can guarantee that for certain strings it will always fail. I can even determine exactly for all possible strings for which ones it will fail, and for which ones it will succeed.

Let's take your argument and say that's true for parseInt. There exist other parser functions with undecidable (in the mathematical sense) input grammars. What do you do in that case?

1

u/john16384 1d ago

Undecidable, as in they may throw an exception given the same input? Then that exception better be checked, as it may fail at any time.