Figure out all possible exceptions that can be thrown?
<p>Is it possible to figure out all possible exceptions that can be thrown that are not necessarily listed by the method's signature.</p>

<p>There are 2 cases</p>

<p>1) runtime exceptions that don't have to be declared (obviously some are obvious, such as null pointer, but there are other runtime exceptions that I'd want to catch that can be due to bad data, which while in development I don't know is bad data yet).</p>

<p>2) exceptions that are subclasses of the exception listed in the signature.</p>

<p>a motivation example</p>

<p>imagine I call getInputStream() on an HttpURLConnection object, it throws java.io.Exception, but in reality, it throws other exceptions that are sublcasses of java.io.Exception (ala java.io.FileNotFoundException), which I'd want to handle in a unique manner (i.e. don't want to lump all java.io.Exceptions together).</p>

<p>so while I can learn in practice by catching java.io.Exception and printing out the actual exception, and then modifying code to handle that case, was wondering if there was a better method :)</p>

<p>thanks</p>

<p>edit: I think people are missing my 2nd problem.  Methods that throw checked exceptions that are fully consistent with the method's signature, but aren't listed in it due to the method's signature only having some sort of base class.</p>
