tag:blogger.com,1999:blog-3237724005744642470.post6045379952082450902..comments2014-09-05T21:54:37.641+01:00Comments on Captain Debug's Blog: Unreachable Catch Block - A Most Unobvious BugRoger Hugheshttp://www.blogger.com/profile/07042290171112551665[email protected]Blogger5125tag:blogger.com,1999:blog-3237724005744642470.post-43558296959500346872012-02-11T11:42:02.281Z2012-02-11T11:42:02.281ZMad Prophet, thanks for the comment. The code show...Mad Prophet, thanks for the comment. The code shown is just sample code used to demonstrate the point that it&#39;s possible to add an exception handlers to your code that are never called and will not be flagged as unreachable catch blocks because the exceptions they catch are sub classes of exceptions that are thrown by the code and that it&#39;s possible to write code that relies on this unreachable code.<br /><br />As for the IOException in main(), that&#39;s there just to make the code compile, if it was removed, you&#39;d have an unhanded exception compilation.Roger Hugheshttp://www.blogger.com/profile/07042290171112551665[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-66333061965397010152012-02-11T10:42:38.967Z2012-02-11T10:42:38.967ZWhy do you throw IOException from the main method....Why do you throw IOException from the main method. Remove it and see what happens.<br /><br />--<br />ilxMad Prophethttp://www.blogger.com/profile/17919396584255640769[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-28213024531516758972012-02-10T13:09:24.927Z2012-02-10T13:09:24.927ZAnother surprise caused by subclassing. When will...Another surprise caused by subclassing. When will we learn?Ricky Clarksonhttp://www.blogger.com/profile/13845104548520132930[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-58434642597835341872012-02-10T07:54:30.946Z2012-02-10T07:54:30.946ZThis behaviour seems clearer if you imagine an int...This behaviour seems clearer if you imagine an interface method throwing a superclass exception type. The compiler cannot know which implementations will be around at runtime, and which subclass flavours of exception they might throw.<br /><br />So client code which invokes the method on an interface type might catch subclass exception types which never could be thrown at runtime.<br /><br />I&#39;ve not tested this theory, though!Ben Rowlandhttp://www.benrowland.net[email protected]tag:blogger.com,1999:blog-3237724005744642470.post-74545760848982820082012-02-02T20:36:44.328Z2012-02-02T20:36:44.328ZI guess IDEA is clever enough to detect this kind ...I guess IDEA is clever enough to detect this kind of error.tcmasterhttp://www.blogger.com/profile/12229570806153597807[email protected]