I think I have an inkling of how you came to this conclusion (I had the same doubt). But no, java.lang.Exception is in fact a checked exception. The JLS 11.2 states that "The unchecked exceptions classes are the class RuntimeException and its subclasses, and the class Error and its subclasses." If you have the following line throw new Exception("yes it's checked"); in a method that doesn't handle Exception in a try/catch block or declare it in the throws clause then you get a compile error. [ June 14, 2002: Message edited by: Junilu Lacar ]
Having read the post given by Junilu the following cite... From JLS 11.2
A compiler for the Java programming language checks, at compile time, that a program contains handlers for checked exceptions, by analyzing which checked exceptions can result from execution of a method or constructor.
...makes me to think the following: If no checked exception is thrown in a try, and no checked exception is caught; compiler doesn't enters the proccess of checking the reachability of catch clauses that trapped non-checked exceptions. On the other hand , maybe Jane is right. The fact that RuntimeException can theoretically be thrown anywhere, applies too within an empty try. In a previous thread somebody said that the reason why an Exception, though a checked one, can be caught without being thrown is because is the parent of RuntimeException. Doesn't make sense that if a kind of exception can be caught without being thrown, its parents will exhibit the same behaviour? After all, the derived exceptions must be trapped,as well, by clauses catching base exceptions.
SCJP2. Please Indent your code using UBB Code
Joined: Jun 04, 2002
Thanks all. I just assumed that since I can catch an Exception without throwing it, then it isn't a checked exception.