test/tools/javac/TryWithResources/ImplicitFinal.java

Fri, 16 Jul 2010 19:35:24 -0700

author
darcy
date
Fri, 16 Jul 2010 19:35:24 -0700
changeset 609
13354e1abba7
child 840
7f8794f9cc14
permissions
-rw-r--r--

6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
6964740: Project Coin: More tests for ARM compiler changes
6965277: Project Coin: Correctness issues in ARM implementation
6967065: add -Xlint warning category for Automatic Resource Management (ARM)
Reviewed-by: jjb, darcy, mcimadamore, jjg, briangoetz
Contributed-by: tball@google.com

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 6911256 6964740 6965277
     4  * @author Maurizio Cimadamore
     5  * @summary Test that resource variables are implicitly final
     6  * @compile/fail/ref=ImplicitFinal.out -XDrawDiagnostics ImplicitFinal.java
     7  */
     9 import java.io.IOException;
    11 class ImplicitFinal implements AutoCloseable {
    12     public static void main(String... args) {
    13         try(ImplicitFinal r = new ImplicitFinal()) {
    14             r = null; //disallowed
    15         } catch (IOException ioe) { // Not reachable
    16             throw new AssertionError("Shouldn't reach here", ioe);
    17         }
    18     }
    21      // A close method, but the class is <em>not</em> Closeable or
    22      // AutoCloseable.
    24     public void close() throws IOException {
    25         throw new IOException();
    26     }
    27 }

mercurial