posted 14 years ago
Thanks a lot guys...my doubt is now clarified.
Wouter, lightning struck my mind when I read "black box" scenario. So, thnx much dude.
The reason for posting out this question was due to my understanding that if you throw a new exception from a catch block and it is not declared in throws clause, the compiler complains...that's why I thought the compiler would be intelligent enough to see that if a called method(in this case someMethod()) abides by "Handle and Declare" rule then none of methods calling it should ever handle those exception as the exception will be caught and taken care of in called method(someMethod()) itself...does my argument makes any sense?
My doubt has been clarified, however, I still want to know opinion of experts out there on my argument.
Basically, if compiler is intelligent enough to throw compile time error on an exception(not declared in throws clause) thrown in catch clause .....why is it not intelligent enough to see that if a method is abiding by "handle and declare" rule for the exception, then all calling methods need not to catch that exception(unless its re-thrown)..and thereby not give any compile time error message.
Thanks
Chintan.