import java.io.IOException; class TryWithResources { final AutoCloseable f1 = null; AutoCloseable f2 = null; void testFields() throws Exception { try (f1; f2) { } catch (Exception ignore) { } } void testLocalVars() throws Exception { final AutoCloseable r1 = null; AutoCloseable r2 = null; AutoCloseable r3 = null; AutoCloseable r4; r4 = null; try (r1; r2; r4; r3) { } r3 = null; } void testType() throws Exception { String s = ""; try (s; this) { } } void testUnhandled() { class Resource implements AutoCloseable { @Override public void close() throws IOException { } } Resource r = new Resource(); try (r) { } } void testResolve() throws Exception { try (r; AutoCloseable r = null) { } try (AutoCloseable r = null; r) { } } void testUnassigned() throws Exception { AutoCloseable r; try (r) { System.out.println(r); } } static class Resource implements AutoCloseable { static Resource create() { return new Resource(); } @Override public void close() { } } void testMoreUsefulParseForIncorrectExpression() { try (new Resource()) {} try (Resource.create()) {} } }