title: Why does try-with-resource require a local variable?
body: <p>With reference to my question <a href="https://stackoverflow.com/questions/16574353/any-risk-in-a-autocloseable-wrapper-for-java-util-concurrent-locks-lock">Any risk in a AutoCloseable wrapper for java.util.concurrent.locks.Lock?</a>, I am wondering why the try-with-resource-statement require a <em>named</em> local variable at all.</p>
  <p>My current usage is as follows:</p>
  <pre><code>try (AutoCloseableReentrantReadWiteLock.Lock l = _lock.writeLock()) {
      // do something
  }        
  </code></pre>
  <p>The variable <code>l</code> is unused inside the try block and only pollutes the namespace. From what I can remember the analogous C# <code>using</code>-statement does not require a local named variable.</p>
  <p>Is there any reason the following could not have been supported, with an anonymous local variable that is closed at the end of try block?</p>
  <pre><code>try (_lock.writeLock()) {
      // do something
  }        
  </code></pre>