tag:blogger.com,1999:blog-178174920347765771.post3065516148392206739..comments2023-10-30T09:20:21.742-07:00Comments on One Div Zero: Checked Exceptions Might Have Their Place, But It Isn't In JavaJames Iryhttp://www.blogger.com/profile/02835376424060382389noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-178174920347765771.post-80168547657036225662014-04-25T10:58:20.989-07:002014-04-25T10:58:20.989-07:00What's the problem with saying that a method t...What's the problem with saying that a method throws A, B, Z, Q and T if they're being thrown by dependencies and it doesn't care about them? You don't really need to catch and rethrow, right? You only catch the ones you do care about.Fetrovskynoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-522773744110148332014-02-16T23:21:14.452-08:002014-02-16T23:21:14.452-08:00They may indeed be an enforceable return value ver...They may indeed be an enforceable return value verification, but shouldn't be used as control because they're slooow to build: Exception construction must fill the whole stacktrace to eventually print it. <br /><br />A better in-between approach, if you want to ensure return checking would be to create a method annotation like @WarnUnusedResult, which would display a warning if the resultBruno Kim Medeiros Cesarhttp://www.brunokim.com.br/noreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-17249925883713211162013-11-09T11:36:40.647-08:002013-11-09T11:36:40.647-08:00I like to think of checked exceptions as additiona...I like to think of checked exceptions as additional return values. They are even stricter, because you can easily ignore return values in Java.<br /><br /><br />So, for most errors (something unexpected happened deep in the call chain, some method is supposed to be overriden, etc.) checked exceptions do not work well. But if you think of a small procedural piece of code, maybe a checked exceptionikknoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-81935995499330536662012-02-27T19:39:32.873-08:002012-02-27T19:39:32.873-08:00Compiler only, I was unaware ... shouldn't we ...Compiler only, I was unaware ... shouldn't we be able to just add a compiler option to stop checking them and be done with it? (or at least, optionally?)John Hinnegannoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-46906654522241373362012-02-27T00:50:10.320-08:002012-02-27T00:50:10.320-08:00FWIW, Oracle rejected the lone throws proposal I p...FWIW, Oracle rejected the lone throws proposal I put forward for fixing checked exceptions. A mistake IMO.Stephen Colebournehttp://twitter.com/jodastephennoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-43774710938101484162012-02-18T02:41:48.018-08:002012-02-18T02:41:48.018-08:00Or, alternatively, checked exceptions can be '...Or, alternatively, checked exceptions can be 'chucked', as one of your article suggests.Antonnoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-47677067516208699572012-02-16T00:21:59.494-08:002012-02-16T00:21:59.494-08:00Checked exceptions are a poor substitute for the V...Checked exceptions are a poor substitute for the Validation concept.Jesper Nordenbergnoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-78266877351820277142012-02-15T22:16:58.548-08:002012-02-15T22:16:58.548-08:00I think you mean java.util.concurrent.Callable, no...I think you mean java.util.concurrent.Callable, not java.lang.Callable.Joel Hockeynoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-82307477831743624192012-02-15T19:33:06.945-08:002012-02-15T19:33:06.945-08:00It's a fundamental tension between covariance/...It's a fundamental tension between covariance/contravariance AFAICT. The set of possible exceptions that can *actually* be thrown often tends to *increase* the deeper you go in an inheritance hierarchy while the set of declared exceptions is only allowed to *decrease*. Without whole-program compilation (and possibly serious type system magic) it seems essentially unresolvable (to me).<br /><PickedUsernamenoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-12668193876639177382012-02-15T18:46:07.371-08:002012-02-15T18:46:07.371-08:00Also, Java's checked exceptions are famous for...Also, Java's checked exceptions are famous for being enforced by the compiler only, as the JVM ignores such concept and treats all exceptions as runtime. I find this dychotomy so funny, it's as if the VM engineers disagreed with the language engineers but would only shale their heads and avoid any arguments; also, it's like they predicted the presence of other languages on the JVM.<brLeonel Gayardnoreply@blogger.comtag:blogger.com,1999:blog-178174920347765771.post-57943192063103923412012-02-15T16:30:17.712-08:002012-02-15T16:30:17.712-08:00I normally think of the selection of checked versu...I normally think of the selection of checked versus unchecked exceptions as falling across a 2x2 matrix. On one axis, we have the question: "Did the client abide by the contract of the interface? Yes or no." On the other axis: "Can the client possibly handle this exception?" There's only one quadrant where a checked exception even begins to make sense -- when the shajranoreply@blogger.com