blob: a85c8a60d2a5f4e5241526052ca3c60f4e8d0697 [file] [view] [edit]
Starting in Java 9, the resource in a try-with-resources statement can be a
reference to a `final` or effectively-`final` variable.
That is, you can write this:
```java
AutoCloseable resource = ...;
try (resource) {
doSomething(resource);
}
```
instead of this:
```java
AutoCloseable resource = ...;
try (AutoCloseable resource2 = resource) {
doSomething(resource2);
}
```
NOTE: the resource cannot be an arbitrary expression, for example `try
(returnsTheResources()) { ... }` is still not allowed.