<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div>> 7. a resource specification of a try-with-resources statement<br />> <br />> Today we get this warning with a TWR-statement if the local is ignored:<br />> <br />> ><br />> javac -Xlint:all MyScopedLock.java<br />> <br />> MyScopedLock.java:23: warning: [try] auto-closeable resource ignored is never referenced in body of corresponding try statement<br />> try(MyScopedLock ignored = l.lock()) {<br />> ^<br />> 1 warning<br />> <br />> So here we may have a clash of philosophies for the enhanced-for and how people<br />> use the `AutoCloseable`.<br /><br /><br />We have a similar use case: a logging framework that uses the close() call to measure the runtime of some code block.<br /><br />It looks like this:<br /><br />try (__ __ = ThreadLogger.block(SomeClass.class, "someAction")) {<br /> // some code<br />}<br /><br />Note we named the helper class and variable already "__" to make clear that they are not used - before Java 8 we used to called them "_“ :-)<br /><br />Big advantages in comparison to e.g. a lambda based solution are that this doesn’t interfere with exceptions and variables outside the try statement can be assigned.<br /><br />There are also more cases reported by other people in https://bugs.eclipse.org/bugs/show_bug.cgi?id=560733 , which why an already implemented warning for such variables by Eclipse was removed again.<br /><br /></div><div dir="ltr" style="mso-line-height-rule:exactly;-webkit-text-size-adjust:100%;direction:ltr;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td align="left" style="padding:22px 0 0;vertical-align:top;"><img src="cid:image985586.png@DC4A06C1.A2C69F7C" border="0" alt="" style="font-size:0;" /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:700;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:33px 0 0;vertical-align:top;font-family:Arial;">Wir stellen uns als Marke neu auf und stehen mehr denn je zusammen.<span style="font-family:remialcxesans;font-size:1px;color:#FFFFFF;line-height:1px;"></span><br /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:3px 0 0;vertical-align:top;font-family:Arial;">Unite ist nun unsere führende Unternehmensmarke.<br /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#FB563E;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:4px 0 0;vertical-align:top;font-family:Arial;"><a href="https://we.unite.eu/de/" target="_blank" id="LPlnk689713" title="we.unite.eu" style="text-decoration:none;color:#FB563E;"><strong style="font-weight:400;">Erfahren Sie mehr</strong></a><br /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:11px 0 0;vertical-align:top;font-family:Arial;">Folgen Sie uns auf <a href="https://www.linkedin.com/company/unite-network" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#28235C;"><strong style="font-weight:400;">LinkedIn</strong></a>, <a href="https://twitter.com/weunite_global" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#28235C;"><strong style="font-weight:400;">Twitter</strong></a> oder <a href="https://www.youtube.com/c/uniteglobal" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#28235C;"><strong style="font-weight:400;">YouTube</strong></a></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#FB563E;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:14px;"><td align="left" style="padding:28px 0 0;vertical-align:top;font-family:'Century Gothic';"><a href="http://unite.eu/" target="_blank" id="LPlnk689713" title="unite.eu" style="text-decoration:none;color:#FB563E;"><strong style="font-weight:400;">unite.eu</strong></a></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:25px 0 0;vertical-align:top;font-family:Arial;">Unite Services GmbH & Co. KG, im Auftrag von Unite<br /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:700;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:12px 0 0;vertical-align:top;font-family:Arial;">Unite Network SE<br /></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:4px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="white-space:nowrap;color:#28235C;font-size:14.67px;font-family:Arial;font-weight:400;font-style:normal;text-align:left;line-height:13.33px;"><tr style="font-size:10px;"><td style="font-family:adobe-clean,sans-serif;">Neumarkt 9, 04109 Leipzig, Deutschland | Amtsgericht Leipzig, HRB 39278<br />Vorstand: Dr. Sebastian Wieser (Vorsitzender), Christel Constant, Peter Ledermann, Dr. Bernd Schönwälder<br />Aufsichtsrat: Karl Mayer‑Rieckh (Vorsitzender)<br /></td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#28235C;font-style:normal;font-weight:700;white-space:nowrap;"><tr style="font-size:10px;"><td align="left" style="padding:12px 0 0;vertical-align:top;font-family:Arial;">Mercateo Deutschland AG</td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="white-space:nowrap;color:#28235C;font-size:14.67px;font-family:Arial;font-weight:400;font-style:normal;text-align:left;line-height:13.33px;"><tr style="font-size:10px;"><td style="font-family:Arial;">Mercateo Deutschland AG Fürstenfelder Straße 5, 80331 München, Deutschland | Amtsgericht München, HRB 243681<br />Vorstand: Dr. Sebastian Wieser (Vorsitzender), Christel Constant, Peter Ledermann, Dr. Bernd Schönwälder<br />Aufsichtsrat: Karl Mayer‑Rieckh (Vorsitzender)<br /></td></tr></table></td></tr><tr style="color:#FB563E;font-size:10px;font-style:normal;font-weight:400;white-space:nowrap;"><td align="left" style="vertical-align:top;font-family:Arial;"><a href="https://www.mercateo.com/procure/" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#FB563E;"><strong style="font-weight:400;">mercateo.com/procure</strong></a></td></tr></table></div></body></html>