| Author |
JVM - Programatically thrown Exceptions
|
palla sridhar
Ranch Hand
Joined: Oct 15, 2007
Posts: 111
|
|
According to Objective 2.6 of K&B, some exceptions are thrown by the JVM and some PROGRAMATICALLY. 1. Can anyone explain how one can say that a particular EXCEPTION is thrown by JVM or thrown PROGRAMATICALLY? 2. Also though it is out of scope of SCJP, how can we decide about CHECKED exceptions, whether they're thrown by JVM or PROGRAMATICALLY ?
|
Thanks and Regards,
[url]www.techlikes.com[/url]
*Nothing is CONSTANT in life, except CHANGE*
|
 |
Doug Slattery
Ranch Hand
Joined: Sep 15, 2007
Posts: 294
|
|
Hi Palla, Here, PROGRAMATICALLY means checked, which also means caught at compile time. There are cases for exceptions to occur which cannot be caught by the compiler due to (bad?) object states at runtime. A good example of this would be in file i/o where you try to open a file for reading that doesn't exist. The compiler doesn't know the file doesn't exist, whence at runtime, an unchecked exception is thrown. Hope this helps. I was a little confused about this too when I started K&B (I think my eyes were glazed over at the time ). There'll be other references to checked/unchecked exceptions further in the book. Aloha, Doug -- Nothing is impossible if I'mPossible [ October 18, 2007: Message edited by: Doug Slattery ]
|
 |
palla sridhar
Ranch Hand
Joined: Oct 15, 2007
Posts: 111
|
|
Hi Doug! Thank you for the explanation. But if you see K&B, there are some RUNTIME exceptions like IllegalArgumentException,IllegalStateException, and NumberFormatException and an AssertionError which all come under UNCHECKED. It is given in the book, that all these are throws PROGRAMATICALLY.. But as you said,
Here, PROGRAMATICALLY means checked.
how can these be throws PROGRAMATICALLY if they're unchecked ?? and
|
 |
ravi satti
Greenhorn
Joined: Oct 16, 2007
Posts: 13
|
|
Hi, I dont know if there is any way to know whether a exception is thrown by JVM or Programmatically. But as the answer to your 2nd question i can make a below statement. An exception thrown Programmatically can be either checked or unchecked, but any exception thrown by JVM is unchecked.
|
 |
 |
|
|
subject: JVM - Programatically thrown Exceptions
|
|
|