Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Class CloneNotSupportedException is a checked Exception and does not extend RuntimeException instead?

Tags:

java

How can the caller of clone() possibly recover if they encounter a CloneNotSupportedException ? Why is it a checked Exception ?

like image 293
Geek Avatar asked Jul 20 '12 07:07

Geek


1 Answers

Why is it a checked Exception?

I suspect the answer is really: "because when Java first came out, there was very little experience of when it would make sense for an exception to be checked." Back then, they didn't have Effective Java :)

There are various things like this - exceptions which are checked but probably shouldn't be, and occasions where the exception is unchecked but should be checked... Integer.parseInt throwing NumberFormatException probably being the clearest example.

like image 176
Jon Skeet Avatar answered Oct 03 '22 05:10

Jon Skeet