aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JVM - Programatically thrown Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JVM - Programatically thrown Exceptions" Watch "JVM - Programatically thrown Exceptions" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM - Programatically thrown Exceptions