Until now, I thought that every Java exception has to be created somewhere by a constructor, as I can create on my own, custom exceptions:
throw new Exception();
But now it seems that I have to handle some exception from JavaMail - MessagingException. It comes from the method Store.close
(inherited from Service
class).
I went there (I need to check when this exception is thrown so I know what can be wrong) and I see that this method calls two other methods - none of them throw an exception!
public synchronized void close() throws MessagingException {
setConnected(false);
notifyConnectionListeners(ConnectionEvent.CLOSED);
}
As far as I understand, this is checked Exception (neither Error nor RuntimeException), so how is it possible that it doesn't have to be declared in any of used by close
method commands? It is also not created here, in this method.