<div dir="ltr"><div dir="ltr">On Tue, Jul 16, 2024 at 10:32 AM Attila Kelemen <<a href="mailto:attila.kelemen85@gmail.com" target="_blank">attila.kelemen85@gmail.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Now look at the gain we might have: We could differentiate between checked and unchecked exceptions for the purpose of better flow analysis. I'm not saying it is nothing but is it really worth the risk of blowing up the JLS?</div></div></blockquote><div><br></div><div>I agree with you that relying on properly checked exceptions opens up a new kind of hole that didn't exist before. In other words, in the places that it doesn't perfectly match reality, the current DA logic always errs on the side of caution, but if it started relying on properly checked exceptions that would mean doing the opposite, even though (arguably) it has the "right" to do so.</div><div><br></div><div>OK so for the sake of argument let's take your position and suppose we don't want to do that. Then every method call becomes a possible branch to the catch clause (regardless of what is caught). In addition, you still have all the special cases like NegativeArraySizeException, and you have Error being thrown anywhere.</div><div><br></div><div>So now basically everything except "trivial stuff" like plain arithmetic must be assumed to possibly throw some kind of exception. And all this buys beyond the original simpler proposal is that the compiler now knows that 
"trailing trivial stuff" can't throw an exception. For example:</div><br><div style="margin-left:40px"><span style="font-family:monospace">final int x;</span></div><div style="margin-left:40px"><span style="font-family:monospace">int neg_x = 0;<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">try {</span></div><div style="margin-left:40px"><span style="font-family:monospace">    x = method();</span></div><div style="margin-left:40px"><span style="font-family:monospace">    neg_x = -x;       // "trailing trivial stuff"<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">} catch (Exception e) {</span></div><div style="margin-left:40px"><span style="font-family:monospace">    x = 0;<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">}</span><br></div><div><br></div><div><div>At this point, is it even worth it to do this more complicated analysis? It's not much gain for all that work when compared to the original simpler fix.</div></div><div><br></div><div>-Archie<br></div></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>