Hi!
A useful change!
Might it also make sense to allow anonymous variables in the
try-with-resource statement?
So that something like `try (() -> System.out.println("closed")) {}`
would work...
Would it make sense to also patch
jdk/src/java.base/windows/classes/java/io/FileDescriptor.java in a
similar manner, as it appears to contain the exactly same code?
Sincerely yours,
Ivan
On 14.01.2015 5:46, joe darcy wrote:
Hello,
Earlier in JDK 9, a language change was made so that if a resource for
a try-with-resources statement is already final or effectively final,
a new resource variable does *not* need to be declared to manage the
variable.
The java.base module should take advantage of this language feature.
I've run an experimental checker for such locations over the base
module and found one candidate where the new language feature can be
used; please review this patch for it:
diff -r d873f6a7d16b
src/java.base/unix/classes/java/io/FileDescriptor.java
--- a/src/java.base/unix/classes/java/io/FileDescriptor.java Tue Jan
13 14:33:54 2015 -0800
+++ b/src/java.base/unix/classes/java/io/FileDescriptor.java Tue Jan
13 18:40:54 2015 -0800
@@ -214,7 +214,7 @@
if (!closed) {
closed = true;
IOException ioe = null;
- try (Closeable c = releaser) {
+ try (releaser) {
if (otherParents != null) {
for (Closeable referent : otherParents) {
try {
The build succeeds with this change and the java.io.FileDescriptor
regression tests pass.
Thanks,
-Joe