JDK 9 RFR of JDK-8068948: Update java.base module to use new try-with-resources statement
Alan Bateman
Alan.Bateman at oracle.com
Wed Jan 14 08:23:10 UTC 2015
On 14/01/2015 02: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.
This looks to me and as Ivan noted, you can update the Windows
implementation too.
For the tests then make sure to run the :jdk_io and :jdk_nio tests as
they will exercise this code well.
-Alan
More information about the core-libs-dev
mailing list