Camusensei
Camusensei

Reputation: 1563

Why/how is org.json.JSONException unchecked?

Reading How to identify checked and unchecked exceptions in java? makes me wonder:

Why is org.json.JSONException unchecked according to maven and eclipse? (no compilation error when not handled)

Both are extending java.lang.Exception according to the javadoc and the source code...


org.JSON.JSONArray produces no error without try/catch: org.JSON.JSONArray produces no error without trycatch


For comparison, here is a checked exception example:

atg.taglib.json.util.JSONArray produces an error without try/catch: atg.taglib.json.util.JSONArray produces an error without trycatch

atg.taglib.json.util.JSONArray produces no error with try/catch: atg.taglib.json.util.JSONArray produces no error with trycatch

Upvotes: 1

Views: 1770

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 280136

You have an old version of the org.json library. I guess they also haven't updated their doc in a while. Since version 20131018, JSONException extends RuntimeException and is therefore an unchecked exception.

You can see it in the source code, here.

Upvotes: 7

Related Questions