<div dir="auto"><div>Oh I agree they serve a purpose. But I think the default is on the wrong side. I think it should warn by default, and let me supress warnings if it indeed is intentional. That's why I am suggesting this compiler warning -- to allow me to opt-in to switching the default.</div><div dir="auto"><br></div><div dir="auto">I was not the one who wrote the empty catches. But I am finding that each one was a mistake of some sort. For almost every one, we could have logged it at least. Leaving them empty was wrong in almost every single instance I found.</div><div dir="auto"><br></div><div dir="auto">And the folks who committed most of these were intern-level devs -- devs who don't know the difference between static and instance.</div><div dir="auto"><br></div><div dir="auto">Now that I am playing clean up, I wanted to make it easier to just bring all these (likely) problematic empty catch blocks to the surface, then put a SuppressWarnings on each one that actually SHOULD be empty (yet to find one, but I concede that is possible).<br><br><div class="gmail_quote gmail_quote_container" dir="auto"><div dir="ltr" class="gmail_attr">On Fri, Jun 20, 2025, 7:11 PM Chen Liang <<a href="mailto:chen.l.liang@oracle.com">chen.l.liang@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Empty catch blocks serve a purpose: They aim to catch the type of exception from the try block, and continue execution from immediately after the try-catch statement. As Brian Goetz often says, let's first look at the problem instead of a solution. What prompted
 you to write those empty catch blocks at first?</div>
<div id="m_8658320473311857897appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="m_8658320473311857897divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> compiler-dev <<a href="mailto:compiler-dev-retn@openjdk.org" target="_blank" rel="noreferrer">compiler-dev-retn@openjdk.org</a>> on behalf of David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank" rel="noreferrer">davidalayachew@gmail.com</a>><br>
<b>Sent:</b> Friday, June 20, 2025 6:00 PM<br>
<b>To:</b> compiler-dev <<a href="mailto:compiler-dev@openjdk.org" target="_blank" rel="noreferrer">compiler-dev@openjdk.org</a>><br>
<b>Subject:</b> Can we get compiler warnings for empty catch blocks?</font>
<div> </div>
</div>
<div>
<div dir="auto">I got burned pretty bad today because of a large number of empty catch blocks.
<div dir="auto"><br>
</div>
<div dir="auto">If a compiler warning is not feasible or not a good idea, that's fine.</div>
<div dir="auto"><br>
</div>
<div dir="auto">But please let me know -- whether yes, no, or otherwise.</div>
</div>
</div>
</div>

</blockquote></div></div></div>