Try-With Resource when AutoCloseable is null : <p>How does the try-with feature work for <code>AutoCloseable</code> variables that have been declared <code>null</code>? </p>

<p>I assumed this would lead to a null pointer exception when it attempts to invoke <code>close</code> on the variable, but it runs no problem:</p>

<pre><code>try (BufferedReader br = null){
    System.out.println("Test");
}
catch (IOException e){
    e.printStackTrace();
}
</code></pre>
